When I add apostrophe to special characters it is shown when opening the excel file. It should be hidden when opening a CSV file and it must shown only when selecting the cell

Hi Aspose Team,

When I add apostrophe to special characters it is shown when opening the CSV file.
image.png (75.8 KB)

It should be hidden when opening a CSV and it must shown only when selecting the cell. Please check the below linked image and it must be shown only in fx tab.

image.png (67.8 KB)

Please help on this I have tried options provided by Aspose.Cells but it is not working.

@prudhviboyina
Please check the attached file which is generated with 24.7 and the following codes:
24.7.zip (6.6 KB)

 Workbook workbook = new Workbook();
 workbook.Worksheets[0].Cells["A1"].PutValue("'abc");
 workbook.Save(dir + "dest.xlsx");

The apostrophe is hidden.

Can you share a template project to show you issue?

Thanks for the reply @simon.zhao!

Apostrophe is not hidden when opening CSV file and apostrophe must be shown only when selecting a cell within CSV.

It is working for XLSX file.

@simon.zhao - Any idea why this is happening for .CSV file?

@prudhviboyina
It is the behaviour of MS Excel.
In MS Excel, if you enter a value starts with Apostrophe , then save it to csv, you will find Apostrophe are missing in csv file.
If you manually add Apostrophe to csv , you will see Apostrophe is not hidden.
We work same as MS Excel now.

If you enter a value starts with Apostrophe in MS Excel, Apostrophe will be a part of Style (Style.QuotePrefix) and other become the value of the cell(Cell.Value)

@prudhviboyina

Aspose.Cells provide loading and saving options to handle Apostrophe which starts at the value.
See following codes:

Workbook workbook = new Workbook();
   workbook.Worksheets[0].Cells["A1"].PutValue("'abc");
  TxtSaveOptions saveOptions = new TxtSaveOptions();
  saveOptions.ExportQuotePrefix = true;
  workbook.Save(dir + "dest.csv", saveOptions);
  
  TxtLoadOptions loadOptions = new TxtLoadOptions();
  loadOptions.TreatQuotePrefixAsValue = false;
  workbook = new Workbook(dir + "dest.csv", loadOptions);
  workbook.Save(dir + "dest.xlsx");
1 Like

@prudhviboyina
Please check the document

1 Like