Jump to content
Sign in to follow this  
DrShepard

XLS 2 XLSX

Recommended Posts

In full generality this is difficult. Not many libraries have full support for reading and writing both formats. If it were me, I'd be looking for a way to change the problem statement.

Share this post


Link to post
54 minutes ago, DrShepard said:

I 'm looking for freeware solution, that's why TMS is not my way

It's a huge amount of work to build such software. Unlikely to find comprehensive free solution for Delphi. Perhaps you should consider my suggestion. 

Share this post


Link to post
1 hour ago, DrShepard said:

I 'm looking for freeware solution, that's why TMS is not my way

No payed, no OLE, ... Puh its getting hard.

I would have suggested to look into (payed) HtmlOffice components as well, but not sure if they can do that you want.

 

Anyway, then maybe UNO + LibreOffice is the last free resort ?

  • Like 1

Share this post


Link to post

@Rollo62 right, libreoffice can convert 

 

"C:\Program Files\LibreOffice\program\soffice.exe" --convert-to xlsx "C:\input_path\file.xls" -outdir "C:\output_path"

Share this post


Link to post

He didn't state what those files contain in terms of formatting or charts etc. Maybe the xls only contains values?

Share this post


Link to post
On 2/9/2021 at 9:22 PM, Attila Kovacs said:

@Rollo62 right, libreoffice can convert 

 


"C:\Program Files\LibreOffice\program\soffice.exe" --convert-to xlsx "C:\input_path\file.xls" -outdir "C:\output_path"

This method doesn't work in cycle.

 

uses
  Winapi.Windows,
  Winapi.ShellApi,
  System.SysUtils;

var
  Command: PWideChar;
  SearchRec: TSearchRec;
  XLSdir, XLSXdir: string;

begin
  try
    XLSdir  := ExtractFilePath(ParamStr(0)) + 'xls';
    XLSXdir := ExtractFilePath(ParamStr(0)) + 'xlsx';

    if FindFirst(XLSdir + '\*.xls',  faAnyFile, SearchRec) = 0 then
      repeat
        if (SearchRec.Name = '.') or (SearchRec.Name = '..') then
          continue;

        WriteLn(SearchRec.Name);
        Command := PChar('/c ""C:\Program Files\LibreOffice\program\soffice.exe" --convert-to xlsx "' + XLSdir + '\' + SearchRec.Name + '" -outdir "' + XLSXdir + '""');
        ShellExecute(GetModuleHandle(nil), 'open', 'cmd.exe', Command, nil, SW_HIDE);
        Sleep(1000);

      until FindNext(SearchRec) <> 0;

  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;

  Write(#13#10 + 'press any key to continue...');
  ReadLn;
end.

 

image.thumb.png.c13efe9bf99f229ea741938c2bb0618a.png

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×