如何使用 JRXlsxExporter 删除导出的 xlsx 文件中的空行?
How to remove empty rows in an exported xlsx file using JRXlsxExporter?
当我使用 JRXlsxExporter 导出 xlsx 文件时,一些结果后出现空行。
我看到XlsReportConfiguration有个静态的属性PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,他的默认boolean值为false
我试图更改该值,但我不能。
有人可以帮我解决这个问题吗?
遵循我的部分代码:
final JRXlsxExporter exporter = new JRXlsxExporter();
XlsxReportConfiguration xlsxReportConfiguration = new SimpleXlsxReportConfiguration();
exporter.setConfiguration(xlsxReportConfiguration);
exporter.exportReport();
[更新]
最后我解决了这个问题。
我使用这样的演员表改变了价值
((AbstractXlsReportConfiguration)xlsxReportConfiguration).setRemoveEmptySpaceBetweenRows(Boolean.TRUE);
在设置导出器配置之前。
希望对大家有所帮助!
这是删除空白列:
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open an existing excel file.
Workbook wb = new Workbook(dataDir+ "SampleInput.xlsx");
// Create a Worksheets object with reference to
// The sheets of the Workbook.
WorksheetCollection sheets = wb.Worksheets;
// Get first Worksheet from WorksheetCollection
Worksheet sheet = sheets[0];
// Delete the Blank Rows from the worksheet
sheet.Cells.DeleteBlankRows();
// Save the excel file.
wb.Save(dataDir+ "mybook.out.xlsx");
这是删除空行:
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open an existing excel file.
Workbook wb = new Workbook(dataDir+ "SampleInput.xlsx");
// Create a Worksheets object with reference to
// The sheets of the Workbook.
WorksheetCollection sheets = wb.Worksheets;
// Get first Worksheet from WorksheetCollection
Worksheet sheet = sheets[0];
// Delete the Blank Rows from the worksheet
sheet.Cells.DeleteBlankRows();
// Save the excel file.
wb.Save(dataDir+ "mybook.out.xlsx");
也试试这个:
1) Set param as mentioned before:
exporterXLS.setParameter
(JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);
2) Making the heigh of all fields exactly the same as the band they
are located on
3) Setting the property "Stretch Type" for all fields on the band to
the value "Relative to Band Height" for all fields on the band.
当我使用 JRXlsxExporter 导出 xlsx 文件时,一些结果后出现空行。 我看到XlsReportConfiguration有个静态的属性PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,他的默认boolean值为false
我试图更改该值,但我不能。
有人可以帮我解决这个问题吗?
遵循我的部分代码:
final JRXlsxExporter exporter = new JRXlsxExporter();
XlsxReportConfiguration xlsxReportConfiguration = new SimpleXlsxReportConfiguration();
exporter.setConfiguration(xlsxReportConfiguration);
exporter.exportReport();
[更新] 最后我解决了这个问题。 我使用这样的演员表改变了价值
((AbstractXlsReportConfiguration)xlsxReportConfiguration).setRemoveEmptySpaceBetweenRows(Boolean.TRUE);
在设置导出器配置之前。
希望对大家有所帮助!
这是删除空白列:
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open an existing excel file.
Workbook wb = new Workbook(dataDir+ "SampleInput.xlsx");
// Create a Worksheets object with reference to
// The sheets of the Workbook.
WorksheetCollection sheets = wb.Worksheets;
// Get first Worksheet from WorksheetCollection
Worksheet sheet = sheets[0];
// Delete the Blank Rows from the worksheet
sheet.Cells.DeleteBlankRows();
// Save the excel file.
wb.Save(dataDir+ "mybook.out.xlsx");
这是删除空行:
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open an existing excel file.
Workbook wb = new Workbook(dataDir+ "SampleInput.xlsx");
// Create a Worksheets object with reference to
// The sheets of the Workbook.
WorksheetCollection sheets = wb.Worksheets;
// Get first Worksheet from WorksheetCollection
Worksheet sheet = sheets[0];
// Delete the Blank Rows from the worksheet
sheet.Cells.DeleteBlankRows();
// Save the excel file.
wb.Save(dataDir+ "mybook.out.xlsx");
也试试这个:
1) Set param as mentioned before: exporterXLS.setParameter (JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);
2) Making the heigh of all fields exactly the same as the band they are located on
3) Setting the property "Stretch Type" for all fields on the band to the value "Relative to Band Height" for all fields on the band.