Tadvlistview save to xls

Hi. I'm trying to save data from TAdvListView to excel file. Everything is fine instead of numbers like 05022019091201 are saved as 5.02202E+12... Is there any way to fix this?

It is Excel that automatically applies this format to such values. You'd need to set the cell format as string in your Excel file.

Hi. Thanks but when i change cell format to text in saved xls file the value stays the same 5.02202E+1. How can i change cell format to text before export when file does not exists yet? I think there should be an option to savetoxls as text values.

There is no formatting control at TAdvListView level. Internally this uses OLE automation and just puts the unformatted value in the variant array that is sent via OLE automation to Excel.
If you want more control for exporting data to Excel, you might consider TAdvStringGrid and TAdvGridExcelIO https://www.tmssoftware.com/site/asg56.asp (that is not using OLE automation but direct XLS file generation) or use TAdvStringGrid in combination with TMS Grid Filters https://www.tmssoftware.com/site/advgridfilters.asp that allows full control.

That would only get you "so far" depending on the version of Excel or other software you use to open the document. If you happen to have text that resembles time and date values, Excel might convert those as well if you do not provide explicit formatting ...

Bruno already recommended TAdvGridExcelIO. In case you have a license of FlexCel, you will get the most sophisticated Excel document generation with it.

Thank You. I have found an easy solution. It is not perfect but it is doing what i want. It is enough to add an apostrophe ' before number to be saved as string in excel.

Just a thought as I ran into this years ago. It might not apply anymore, I just want to point out something that you might encounter when international versions are in play.

Did you check this on an European Excel? Those use " instead of ' and it might not work.

Hi. My Client is using only English version of ms excel so apostrophe is good option.