English 中文(简体)
CSV储蓄的开放式办公室宏观
原标题:openoffice calc macro for CSV saving
  • 时间:2009-08-23 17:52:59
  •  标签:

鉴于:我记录在公开办公处简单,以拯救我的工作单,作为加拿大社会保障协会的档案。 这里就是这样。

sub toCSV
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///path/csv/filename.csv"
args1(1).Name = "FilterName"
args1(1).Value = "Text - txt - csv (StarCalc)"
args1(2).Name = "FilterOptions"
args1(2).Value = "59,34,76,1"
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1())
end sub

问题: 我想为这一职能增添一些特点。 1. 我需要获得目前的XLS档案名称,以便我在静态道路上能够做到这一点。 因此,文件http://path/csv/将永远不变,filename.csv将来自filename.xls。 2. 确实,我不得不在filename-revision01.xls上做一些顶替,以最终获得filename.csv

我可以做妥善的校对,我只想看一下扼杀的背心,如何获得目前的档案名称,以及如何在宏观范围内书写ex语。

BTW,这一措辞是什么?

最佳回答

This is the solution I came up with to help in exporting a CSV (with my export options, filename adjustment, and file location) with one click.
I m on a Mac, so the file paths will be for such an operating system. The information that helped me do this is here.

REM  *****  BASIC  *****
sub toCSV
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
FileURL = ThisComponent.URL
oMasterScriptProviderFactory = createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory")
oMasterScriptProvider = oMasterScriptProviderFactory.createScriptProvider("")
oScriptReplace = oMasterScriptProvider.getScript("vnd.sun.star.script:Tools.Regex.js?language=JavaScript&location=user")
sReturn = RegExpReplace(oScriptReplace, FileURL, "(.*)/(w*-w*)(-revisiond*)+.xls", "i", "$2.csv")
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///Users/joe/Documents/mydocuments/trunk/my%20projects/dictionary/verbsXLS/proofed/csv/" + sReturn
args1(1).Name = "FilterName"
args1(1).Value = "Text - txt - csv (StarCalc)"
args1(2).Name = "FilterOptions"
args1(2).Value = "59,34,76,1"
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1())
end sub

function RegExpReplace(oScriptReplace as Object, sSource as String, sRegExp as String, sGlobUpcase as String, sReplace as String) as String
RegExpReplace = oScriptReplace.invoke(Array(sSource, sRegExp, sGlobUpcase, sReplace ), Array(), Array())
end function

这里是上述宏观依靠的 j脚石。 该档案名称为~/Library/Application。 Support/OpenOffice.org/3/user/codes/javascript/Tools/Regex.js, 上文硬编码和参考。

sSource     = String(ARGUMENTS[0])
sRegExp     = String(ARGUMENTS[1])
sGlobUpcase = (ARGUMENTS[2])
sReplace    = String(ARGUMENTS[3])
myRe   = new RegExp(sRegExp, sGlobUpcase)
ret = sSource.replace(myRe, sReplace)

最后,,这一员额详细介绍了如何添加一个工具条条条令,以一个点击来管理你的宏观。

问题回答

暂无回答




相关问题
热门标签