Skip to content

Instantly share code, notes, and snippets.

@sh2
Created October 20, 2012 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sh2/3922054 to your computer and use it in GitHub Desktop.
Save sh2/3922054 to your computer and use it in GitHub Desktop.
Load a CSV file to LibreOffice Calc.
Sub Main
oFilePicker = createUnoService("com.sun.star.ui.dialogs.FilePicker")
oFilePicker.appendFilter("Response Files (*_r.csv)", "*_r.csv")
oFilePicker.appendFilter("All Files (*.*)", "*.*")
If oFilePicker.execute() = com.sun.star.ui.dialogs.ExecutableDialogResults.OK Then
sFiles() = oFilePicker.getFiles()
oSheet = ThisComponent.getSheets.getByName("Data")
oSheet.link(sFiles(0), "", "Text - txt - csv (StarCalc)", "44,34,76,1", com.sun.star.sheet.SheetLinkMode.NORMAL)
oSheet.setLinkMode(com.sun.star.sheet.SheetLinkMode.NONE)
ThisComponent.calculateAll()
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment