Mantieni i separatori per le righe vuote durante l esportazione di fogli di calcolo in formato CSV
Mantieni i separatori per le righe vuote durante l’esportazione di fogli di calcolo in formato CSV
Aspose.Cells for Python via .NET fornisce la capacità di mantenere i separatori di riga durante la conversione di fogli di calcolo nel formato CSV. Per fare ciò, è possibile utilizzare la proprietà keep_separators_for_blank_row della classe TxtSaveOptions. keep_separators_for_blank_row è una proprietà booleana. Per mantenere i separatori per le righe vuote durante la conversione del file Excel in CSV, impostare la proprietà keep_separators_for_blank_row su true.
Il seguente codice di esempio carica il file Excel di origine. Imposta la proprietà keep_separators_for_blank_row su true e lo salva come output.csv. La schermata mostra il confronto tra il file Excel di origine, l’output predefinito generato durante la conversione del foglio di calcolo in CSV e l’output generato impostando keep_separators_for_blank_row su true.
Codice di Esempio
from aspose.cells import TxtSaveOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
filePath = dataDir + "Book1.xlsx" | |
# Create a Workbook object and opening the file from its path | |
wb = Workbook(filePath) | |
# Instantiate Text File's Save Options | |
options = TxtSaveOptions() | |
# Set KeepSeparatorsForBlankRow to true show separators in blank rows | |
options.keep_separators_for_blank_row = True | |
# Save the file with the options | |
wb.save(dataDir + "output.csv", options) |