I have a text file that im converting to Excel using Aspose Cells for .NET.
My data contains numeric values that are being converted to scientific notation, so to counteract that I added an apostrophe to the beginning of all the the text in the file.
The file converts fine but in the final file I can still see the apostrophe when its supposed to be hidden as per Excels default behavior. I tried toggling this with the recommended code book.Settings.QuotePrefixToStyle = false;
but the result is the same.
Here is my code below
var book = new Aspose.Cells.Workbook(source ".tmp.txt");
//book.Worksheets[0].Cells.ConvertStringToNumericValue();
book.Settings.QuotePrefixToStyle = false;
book.Save(dest,Aspose.Cells.SaveFormat.Auto);
book.Dispose();
CodePudding user response:
You do not need to add apostrophe at the beginning of all values in the text file. So, kindly use your original text file or do remove "'" with the values in the file (and re-save it). Now Please try the following sample code with your file to accomplish your task. The output file will not contain scientific notation rather original values/data.
e.g.
Sample code:
TxtLoadOptions options = new TxtLoadOptions();
options.ConvertNumericData = false;
Workbook book = new Workbook(source ".tmp.txt", options);
book.Save(dest, Aspose.Cells.SaveFormat.Auto);
You may also post your queries or issue samples in Aspose.Cells forum, we can help you there.
PS. I am working as Support developer/ Evangelist at Aspose.