我实际上是使用php脚本导入.ods
文件并将其转换为.csv
,以便将所有内容添加到SQL表中,但是当我上传多张{{1}时它仅转换第一张纸。
要转换它,我使用命令(分为两行以便于阅读):
ods
我如何处理其他工作表?
答案 0 :(得分:0)
我想出了同样的问题,这就是我解决它的方法:
以here中的答案为参考,我构建了这个libreoffice基本脚本:
REM ***** BASIC *****
Sub convertSheetsToCSVs
Dim fileProps(1) as new com.sun.star.beans.PropertyValue
sheets = ThisComponent.Sheets
fileProps(0).Name = "FilterName"
fileProps(0).Value = "Text - txt - csv (StarCalc)"
fileProps(1).Name = "FilterOptions"
fileProps(1).Value = "09,,22,1,,0,false,true"
'The previous line can be changed to modify filter options as explained in
'https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options#Filter_Options_for_the_CSV_Filter
folder = "file:///home/your_folder_path/"
i = 0
Do While sheets.Count > i
sheet = sheets.getByIndex(i)
cntrllr = ThisComponent.CurrentController
cntrllr.setActiveSheet(sheet)
sURL = folder & sheets.ElementNames(i) & ".csv"
ThisComponent.storeToURL(sURL, fileProps())
i = i + 1
Loop
End Sub
如果你想在控制台中这样做,肯定有办法,但我不知道如何。