Empty cells are missing in xml output

I am using Aspose 8.1.0


When I try to generate the XML output using SpreadsheetML2003SaveOptions, it has been observed that empty cells are missing in the generated XML.

For your reference, I have attached the xlsx file being used and the XML output generated by Aspose.

Following is the code snippet for the same:

Workbook workbook = new Workbook(“C:/187208/TestDoc_1.xlsx”);
com.aspose.cells.Worksheet selectedWorksheet = workbook.getWorksheets().get(“table1”);

//Create Range
Range sourceRange = selectedWorksheet.getCells().createRange(“A1:G3”);

Workbook targetWorkbook = new Workbook(FileFormatType.XLSX);
WorksheetCollection targetWsc = targetWorkbook.getWorksheets();
com.aspose.cells.Worksheet targetWs = (com.aspose.cells.Worksheet)targetWsc.get(0);
Range targetRange = targetWs.getCells().createRange(0, 0, sourceRange.getRowCount(), sourceRange.getColumnCount());

PasteOptions options = new PasteOptions();
options.setPasteType(PasteType.ALL);

targetRange.copy(sourceRange, options);

File xmlFile = new File(“C:/187208/AposeGenerated.xml”);

SpreadsheetML2003SaveOptions spreadsheetML2003SaveOptions = new SpreadsheetML2003SaveOptions(SaveFormat.SPREADSHEET_ML);

targetWorkbook.save(xmlFile.getAbsolutePath(), spreadsheetML2003SaveOptions);

You can observer in the output, for the second row there is only one cell whereas it should have 7 cells and for the third row there are only two cells whereas it should have 7. Missing cells are leading to wrong placement of the data.


Character formatting
Test firs cell data
and last but one

Thanks,
Neeraj

Hi,


I have tested your scenario/ case a bit. I have implemented your scenario in MS Excel manually, I opened the template XLSX file into MS Excel and then select the range A1:G3 in the respective sheet and Copy it, now I opened a new workbook into MS Excel and paste it (values), I re-saved the file to XML Spreadsheet 2003 format. When I open the file into notepad, I see similar representation of data in the cells for your highlighted portion. Could you try to do the steps manually in MS Excel and see if you could see any difference with the output file generated by Aspose.Cells, if you find any issue/ major difference, please provide the output file and steps involved. Also provide some screen shots for comparisons to highlight the problematic areas of the XML file, we will check it soon.

Thank you.

Hi,


As suggested, I have tested the same using Apose Cells 8.3.1.

In contrary to your findings, the behaviour is not the same. The xml file produced using Aspose is not the same what is [produced after copy, pasting the selected range to new Book and getting its xml using XML Spreadsheet 2003.

Attached are both xml files for your reference.

Kindly verify.

Thanks,
Neeraj

Hi,


Thanks for the template files.

Well, I again tested your scenario in MS Excel manually, I opened the template XLSX file into MS Excel and then select the range A1:G3 in the respective sheet and Copy it, now I opened a new workbook into MS Excel and paste it (values), I re-saved the file to XML Spreadsheet 2003 format, the file is not the same.

Could you give details of your steps by both Ms Excel and share code segment via Aspose.Cells APIs. Also. Please also provide some screen shots for comparisons to highlight the problematic areas of the XML files (generated by both MS Excel and Aspose.Cells APIs), we will check it soon.

Thank you.