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

Free Support Forum - aspose.com

Converting Aspose worksheet to.dif fomat drops zero

Hello

We have zip code column in Aspose worksheet which is a strin from my DataSet. But this is considered as a numeric column and warning message will be displayed in the Excel sheet.

When we try to do a SaveAs to convert excel to '.dif' format, the preceding zero's in the column is dropped.

I tried to suppress the warning error by using Cell.PutValue(string stringvalue, bool isConverted), but I'm losing my string format.

Please advise to fix this issue. Let me know if you have any questions.

Hi,


Aspose.Cells should work the same way as MS Excel does for dif conversion.

Could you give us your sample code, input + output files. We will check it soon.

Thank you.

Given below is our code sample. Here, when I try to save the workbook in dif format, I'm losing the zero's in the front of the string.

workbook.Save(fileName + ".xlsx", FileFormatType.Excel2007Xlsx);
workbook.SaveAs(fileName + ".dif", XlFileFormat.xlDIF, Type.Missing, Type.Missing, Type.Missing, false, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

Please check and let me know if you have any questions. Help me to proceed further.

Hi,


Your code (in the below line) looks to me is VSTO code, so we cannot have any responsibility for this issue. We are due to fix the issue, if the Excel file “XLSX” (generated by Aspose.Cells for .NET) have any issue while viewing in MS Excel.

Thank you.

Hi,

We are posting Sample application where we are able to reproduce this issue.

For Output File it will be saved in C Drive, there will be one excel file and one more DIF format.

We can compare the two fileswhere the zipcode is missing zero's in dif format.

Thanks,

Sri Prashanna

Hi Sri Prashanna,


" string sTempFilePath = ConfigurationManager.AppSettings[“TempFolderName”].ToString();
string GUID = Guid.NewGuid().ToString();
string fileName = sTempFilePath + “Test” + “_” + “2011” + GUID;
workbook.Save(fileName + “.xlsx”, FileFormatType.Excel2007Xlsx);
Application excel = new Application();
Microsoft.Office.Interop.Excel.Workbook workbook1 = excel.Workbooks.Open(fileName + “.xlsx”, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
workbook1.SaveAs(fileName + “.dif”, XlFileFormat.xlDIF, Type.Missing, Type.Missing, Type.Missing, false, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);"

As I told you earlier, we cannot fix the issue for dif format as the file is generated by your VSTO (Office Automation API). We can fix the issue for the XLSX file generated by Aspose.Cells.

If you find the issue for your XLSX file (as you told us this is not the case), then we can fix the issue.

By the way, since you are using some older versions, we recommend you to use our latest versions/fix e.g
Please download: Aspose.Cells for .NET v7.0.3.4 and try if it makes any difference.

Thank you.

Hi,


Also, I confirm and check to convert the XLSX file (generated by Aspose.Cells) to DIF format in MS Excel manually, the leading zeros are removed, so it is a limitation of MS Excel for DIFF format.

Thank you.

Hi

Thanks for the reply. Is there a way to Convert the Aspose Workbook to .dif format withour losing my data.

I tried using Cell.PutValue(string stringvalue, bool isConverted), but again it's dropping zero in the front of the string.

Can you provide me some sample to solve this issue using Aspose cells.

Thanks Again

Prasanna

Hi,


Aspose.Cells does not support Dif format, it does support txt, csv, tab delimited formats though.

After closely look into it, I think it is MS Excel behavior that does not show the leading zeros, so we cannot do anything for it. The leading zeros are there with the data in your Dif format (by Office Automation APIs). For confirmation, you may check: open your Dif (output) file into Notepad and you will see the leading zeros are there. So, it is Ms Excel limitation or behavior.

Thanks for your understanding!