Recent

Author Topic: Trying to make a CSV to Excel converter  (Read 14391 times)

MISV

  • Hero Member
  • *****
  • Posts: 815
Re: Trying to make a CSV to Excel converter
« Reply #15 on: October 19, 2016, 02:33:59 pm »
Have you looked at FPSpreadsheet? It works very well to read and write Excel and LibreOffice files. I use my own code to read and write csv and tab delimited files, but FPSpreadsheet and TStringList are csv friendly.

Cheers,
VTwin

Edit: I see you mentioned fpspreadsheet already. I guess it does not meet your needs?

I still use Delphi for Windows - but use Lazarus for Mac targeting. Long term, I will be switching to Lazarus completely since I doubt am not going to buy any more Delphi versions. (I got everything unicode/string handling abstracted, so it works pretty well targeting Delphi 2010 win32, Delphi XE2 win64 and Lazarus 1.4.4 Mac currently)

wp

  • Hero Member
  • *****
  • Posts: 13401
Re: Trying to make a CSV to Excel converter
« Reply #16 on: October 19, 2016, 03:53:55 pm »
Zoho
https://sheet.zoho.com/sheet/excelviewer
(Reason I use this is that I saw it mentioned many places. However my experience wih Zoho is similar to that of other online excel reader)

test.xls works
test.xlsx works
test-b2.xls fails
test-b5.xls works
test.xml not accepted
test.ods works

where "works" = no errors reported
Thanks for the link. Yes, this indicates that you cannot view Excel2 worksheets with the Zoho viewer even if you add missing records. BTW, why don't you use OpenOffice/LibreOffice? They will display BIFF2, for sure, and they will even display CSV.

I still use Delphi for Windows - but use Lazarus for Mac targeting. Long term, I will be switching to Lazarus completely since I doubt am not going to buy any more Delphi versions. (I got everything unicode/string handling abstracted, so it works pretty well targeting Delphi 2010 win32, Delphi XE2 win64 and Lazarus 1.4.4 Mac currently)
Take this as an opportunity to begin moving to Lazarus right now. Knowing only Delphi, Lazarus may feel a bit strange, but believe me: it is the other way round if I now write a litte program in Delphi. Just to give you an appetizer, this is the code required to write the test files which you uploaded to zoho:
Code: Pascal  [Select][+][-]
  1. project fpsdemo;
  2.  
  3. {$mode delphi}{$H+}
  4.  
  5. uses
  6.   Classes, SysUtils, fpsTypes, fpspreadsheet, fpsallformats;
  7.  
  8. var
  9.   MyWorkbook: TsWorkbook;
  10.   MyWorksheet: TsWorksheet;
  11.   MyDir: string;
  12.  
  13. begin
  14.   MyDir := ExtractFilePath(ParamStr(0));
  15.  
  16.   MyWorkbook := TsWorkbook.Create;
  17.   try
  18.     MyWorksheet := MyWorkbook.AddWorksheet('Sheet with Umlauts ÄÖÜ');
  19.  
  20.     MyWorksheet.WriteRowHeight(0, 2.5, suLines);
  21.     MyWorksheet.WriteText(0, 0, 'abc' + #13 + 'cde');
  22.     MyWorksheet.WriteWordwrap(0, 0, true);
  23.  
  24.     MyWorksheet.WriteNumber(0, 3, 12345.122);
  25.     MyWorksheet.WriteDateTime(0, 5, now, nfShortDate);
  26.  
  27.     MyWorksheet.WriteNumber(1, 0, 1.123);
  28.     Myworksheet.WriteText(1, 1, 'ABC');
  29.     MyWorksheet.WriteFont(1, 1, 'Arial', 12, [fssBold], scRed);
  30.  
  31.     MyWorksheet.WriteText(1, 3, 'ABC');
  32.  
  33.     Myworksheet.WriteText(2, 3, 'test');
  34.  
  35.     MyWorksheet.WriteBackgroundColor(7, 5, scYellow);
  36.     MyWorksheet.WriteText(7, 5, 'MERGED');
  37.     Myworksheet.MergeCells(7, 5, 8, 7);
  38.  
  39.     Myworkbook.WriteToFile(MyDir + 'test.xls', sfExcel8, true);
  40.     MyWorkbook.WriteToFile(MyDir + 'test-b5.xls', sfExcel5, true);
  41.     MyWorkbook.WriteToFile(MyDir + 'test-b2.xls', sfExcel2, true);
  42.     MyWorkbook.WriteToFile(MyDir + 'test.xlsx', sfOOXML, true);
  43.     MyWorkbook.WriteToFile(MyDir + 'text.xml', sfExcelXML, true);
  44.     MyWorkbook.WriteToFile(MyDir + 'test.ods', sfOpenDocument, true);
  45.   finally
  46.     MyWorkbook.Free;
  47.   end;
  48. end.

MISV

  • Hero Member
  • *****
  • Posts: 815
Re: Trying to make a CSV to Excel converter
« Reply #17 on: August 28, 2019, 11:53:15 pm »
Just for reference I got http://avemey.com/files.php?lang=en working for xlsx in both Delphi and Lazarus (my "own" solution was not good enough, xls files caused problem some places - never got BIFF5 fully working. I would still be interested in XLS though)


 

TinyPortal © 2005-2018