Trim Leading Blank Rows and Columns while exporting spreadsheets to CSV format
Possible Usage Scenarios
Sometimes, your Excel or CSV file has leading blank columns or rows. For example, consider this line
,,,data1,data2
Here the first three cells or columns are blank. When you open such a CSV file in Microsoft Excel, then Microsoft Excel discards these leading blank rows and columns.
By default, Aspose.Cells for Python via .NET does not discard leading blank columns and rows on saving but if you want to remove them just like Microsoft Excel does, then Aspose.Cells for Python via .NET provides TxtSaveOptions.trim_leading_blank_row_and_column property. Please set it to true and then all the leading blank rows and columns will be discarded on saving.
Trim Leading Blank Rows and Columns while exporting spreadsheets to CSV format
The following sample code loads the source excel file which has two leading blank columns. It first saves the excel file in CSV format without any changes and then it sets TxtSaveOptions.trim_leading_blank_row_and_column property to true and saves it again. The screenshot shows the source excel file, output CSV file without trimming, and the output CSV file with trimming.