We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Cells.dll (build 5.3.2.3) causes data loss

I created a large workbooks (26 MB) to test Aspose functionality. I found that simply using Aspose to Open and then Save the workbook caused considerable data loss. I downloaded the latest version of Aspose.Cells.dll - build 5.3.2.3 to ensure I had the latest code. Here are the testing steps I followed.

1. Generate a large workbook that contains data only.

2. Save the workbook in the following formats - .xls, .xlsx, .xlsm

3. Verify the size of each workbook by right click -> properties -> file size.

4. I then verified that Excel doesnt do anything to the file size. I simply opened each workbook and performed "save as" to over write the original. The file sizes did not change.

5. Lastly, I created a C# .NET windows forms app that uses Aspose to process each workbook.

Here is the code I tested with:

using System;
using System.IO;
using System.Windows.Forms;
using Aspose.Cells;

namespace AsposeTester
{
public partial class Form1 : Form
{
private Workbook m_oActiveWorkbook = null;
private string m_sFilePath = string.Empty;

public Form1()
{
InitializeComponent();
License license = new License();
license.SetLicense("Aspose.Total.lic");
}

~Form1()
{
m_oActiveWorkbook = null;
}

private void button1_Click(object sender, EventArgs e)
{
try
{
string sFilePath = "c:\\Example1.xlsx";
m_oActiveWorkbook = new Workbook(sFilePath);

try
{
m_oActiveWorkbook.Save(sFilePath, SaveFormat.Xlsx); //Format was changed for each workbook tested.
MessageBox.Show("Processing is complete. Please note that the file size is now reduced from the original. Data loss has occurred. The application will now close.");
Application.Exit();
}
catch (Exception ex1)
{
MessageBox.Show("Unable to save workbook", ex1.Message);
Application.Exit();
}
}
catch (Exception ex)
{
MessageBox.Show("Unable to open workbook. Please copy the test workbook to the root of c:\\ directory. Original Error " + ex.Message);
Application.Exit();
}

Application.Exit();
}
}
}

6. Here are the testing results:

.xls - 75.9MB before Aspose processing - 75.9 after Aspose processing (no apparent loss)

.xlsx - 26.2MB before Aspose processing - 15.6MB after Aspose processing (10MB+ lost!!!)

.xlsm - 26.2MB before Aspose processing - 15.6MB after Aspose processing (10MB+ lost!!!)

*I am using a full Aspose license.

The question is: Why is Aspose causing data loss?

Hi,

We don’t export the cell names to file if the cells are adjacent for performance.

If you still want to export them, please try the following code:

C#

OoxmlSaveOptions xlsxSaveOptions = new OoxmlSaveOptions();

xlsxSaveOptions.ExportCellName = true;

workbook.Save(@“D:\FileTemp\dest.xlsx”, xlsxSaveOptions);

I applied the change you suggested to the code. After processing the xlsx, xlsm, and xls workbooks with the new save option, the xlsm and xls was rendered corrupt and could not be opened by Excel. The xlsx showed significantly less data loss and could be opened by Excel.

Hi,


Thank you for providing us your test results.
We have logged an investigation for your said issue under TicketID CELLSNET-27446. We will keep you posted on this.
Original Size Excel Save As Aspose Save
XLSX Aspose ExportCellName false - DEFAULT 12,259 KB 11,937 KB 4,675 KB
XLSX Aspose ExportCellName true 12,259 KB 11,937 KB 10,061 KB
XLS 10,585 KB 10,580 KB 11,063 KB

We are trying to determine the file information that is lost when we save the file with Aspose. What else is stripped from the XML besides the CellNames? With the above information from testing, when I set the ExportCellName property to true, there is still almost 2 MB difference between the two files.

Edit: Looks like there is a bunch of formatting removed when it comes to 's and 's

Thanks,

Eric

Hi,

Thanks for your feedback. We have logged your comment. Hopefully, It will be helpful in sorting out this issue.

Thank you. I re-posted this in the Priority Support Forum as thread #306078.

I did not realize this was posted in the general Aspose Cells forum.

We have a customer who is anxious about this difference in file size.

Hi,

Since we know you are a priority customer, so your issue was logged as a Priority Support issue.

Also, we have commented in your other thread in Priority Support Forum.

Hi,

1 - The main difference is: We do not export the cell name in default mode, so the file is smaller than Excel.

If ExportCellNames is true, the cell name will be exported to generated file.

If you find corrupted file, please share with us the file.

2 - The difference of Style.xml:

a) : if it ‘s default setting, we will not export them.

b) : if they are duplicate or never referred by other (Cell,Row,Column), we will not export them.

3 - As
you know, xlsx file is a zip file which contains several xml files and
other files. The compress level is different with MS Excel.

So could you compare unzipped files? And we will look into MS Excel’s compress level