I have a long string that I want to save to CSV. I use the following code to convert the string to blob and save as a file:

Attachment newFile = new Attachment();
newFile.Name = getReportFileName();
newFile.Body = Blob.valueOf(csvContent);

However, when I open the csv, I see some numbers are formatted like 1.00E+01 instead of 10. I thought this is an Excel issue and opened the raw file in another editor (Notepad++) and still see the same format, which makes me think it is an issue with the generated file and not Excel. Obviously, I could not find anything related in the Blob Class documentation and when I debug the values in the code before saving to file, the numbers are shown correctly. The problematic values are calculated with this code


What can be causing this issue?

1 Answer 1


You have two possible solutions. You can turn the decimal (i'm guessing that) to a plain string with the toPlainString() method.

Returns the String value of this Decimal, without using scientific notation.


Or you can tell excel to treat the column as a numeric value. It should just convert it to normal numbers for you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .