Keep the leading zeros when saving the file

Hi. I am using the latest version on Aspose.Cells. And i write my code in c#.

Here is my goal:
I want to save a string which is zeros like “000000” to a cell

My problem is :
i used both cell.PutValue(“000000”, true) and cell.PutValue(“000000”)

however, after i save the file. the cell could only show 1 zero but what i want is show all zeros.

I used a blank new excel. And i also tried using Gernal format or text format. Both of them did not give me mine expected result.

Is there any setting in excel or any saving option in aspose can help me solve this problem?

@nickMina,
For saving a string value of zeros, you can set text format for the cell. The code sample below can be used for this purpose:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Cell cell = worksheet.Cells["A1"];
cell.PutValue("000000");
// Set cell format as text
Style style = cell.GetStyle();
style.SetCustom("@" , false);
cell.SetStyle(style);
workbook.Save("TextFormatting.xlsx");

Let us know your feedback.

That works fine! Thank you very much!

@NickMina,
You are welcome.