Outils pour utilisateurs

Outils du site


prog:libreoffice:macros

Enregistrer toutes les feuilles d'un tableau en plusieurs fichier .csv

Sub Main
	document = ThisComponent
 
	' Use the global string tools library to generate a base filename for each CSV
	' based on the current prefixless filename
	GlobalScope.BasicLibraries.loadLibrary("Tools")
	BaseFilename = Tools.Strings.GetFileNameWithoutExtension(document.getURL(), "/")
 
	' Work out number of sheets for looping over them later.	
	Sheets = document.Sheets
	NumSheets = Sheets.Count - 1
 
	' Set up a propval object to store the filter properties
	Dim Propval(1) as New com.sun.star.beans.PropertyValue
	Propval(0).Name = "FilterName"
	Propval(0).Value = "Text - txt - csv (StarCalc)"
	Propval(1).Name = "FilterOptions"
	Propval(1).Value ="44,34,76,1,1"   'ASCII  44 = ,  34 = "
 
	For I = 0 to NumSheets
		' For each sheet, assemble a filename and save using the filter
		SheetName = Sheets(I).Name
		document.getCurrentController.setActiveSheet(Sheets(I))		
		Filename = Tools.Strings.DirectoryNameoutofPath(ThisComponent.getURL(),"/") + "/" + BaseFilename + "-" + SheetName + ".csv"
		FileURL = convertToURL(Filename)
		document.StoreToURL(FileURL, Propval())
	Next I
 
End Sub

Exporting all Libreoffice worksheets as CSV : Exporting all Libreoffice worksheets as CSV _ J-P Stacey Archive du 12/09/2014 le 28/04/2020

Filter Options : Filter Options — Apache OpenOffice Wiki Archive du 16/08/2018 le 28/04/2020

XStorable Interface Reference : LibreOffice_ XStorable Interface Reference Archive le 28/04/2020

prog/libreoffice/macros.txt · Dernière modification : 2020/04/28 21:20 de root