用显示的格式(缩进)读取excel文件(.xlsx或.xls)?

我想要读取文件中的所有数据,与打开excel文件时显示的格式相同。 我的意思是相同的缩进,这是设置在“格式单元格”。 我试过的所有方法都正常,但删除缩进(格式)。

已经检查过ExcelDataReader,Oledb,Interop。

您可以使用EasyXLS Excel Reader 。 您可以读取xls或xlsx文件。

此代码示例读取A1单元格的值和缩进:

ExcelDocument workbook = new ExcelDocument(); // Read XLSX file workbook.easy_LoadXLSXFile("file.xlsx"); // Get the table of the first worksheet ExcelTable table = ((ExcelWorksheet)workbook.easy_getSheetAt(0)).easy_getExcelTable(); //Get the value from A1 cell String value = table.easy_getCell(0, 0).getValue(); //Get the indent from A1 cell int indent = table .easy_getCell(0, 0).getStyle().getIndent(); 

您也可以阅读其他格式设置。 以类似的方式,你也可以读取xls文件。