Forum > Beginners

ShellApi in Lazarus.

(1/3) > >>

seghele0:
The procedure below works well.
But I would also like to activate the *.xlsx file, which is located in the folder of my exe program, to run either Excel or LibreOffice-Calc.
Van you please provide an example with the code?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFmain.MenuItemExportXLSXClick(Sender: TObject);var  varWorkbook: TsWorkbook;  varWorksheet: TsWorksheet;  varR, varC: Integer;  varFilename: String;begin  // Create a workbook  varWorkbook := TsWorkbook.Create;  try   try    // Add a worksheet to the workbook    varWorksheet := varWorkbook.AddWorksheet('Export-Wiezen ');    // Write the title row    for varC := 0 to StringGrid1.ColCount-1 do      varWorksheet.WriteText(0, varC, StringGrid1.Cells[varC, 0]);    // Write the data cells    for varR := 1 to StringGrid1.RowCount-1 do    begin      for varC := 0 to StringGrid1.ColCount-1 do        case varC of          //0: TEKST          0: varWorksheet.WriteText(varR, varC, StringGrid1.Cells[varC, varR]);          //1:  CIJFERS          1: varWorksheet.WriteText(varR, varC, StringGrid1.Cells[varC, varR]);          //2:  CIJFERS          2: varWorksheet.WriteText(varR, varC, StringGrid1.Cells[varC, varR]);          //3:  CIJFERS          3: varWorksheet.WriteText(varR, varC, StringGrid1.Cells[varC, varR]);          //4:  CIJFERS          4: varWorksheet.WriteText(varR, varC, StringGrid1.Cells[varC, varR]);        end;    end;    varFilename := 'Wiezen-'+FormatDateTime('yyyy-mm-dd__hh.mm', now)+'.xlsx';    varWorkbook.WriteToFile(varFilename, sfOOXML, true);   //// ShellExecute(0, 'open', PChar(), 'varFilename', '', SW_SHOWNORMAL);   except    On E: Exception do    begin      Showmessage(E.Message);    end;  end;  finally    XLSXproc;   // Eigen procedure:('EXPORT naar XLSX bestand is voldaan! ');    // Destroy the workbook after usage.    varWorkbook.Free;  end;end;   In uses:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  Windows,  Dialogs, Interfaces, Classes, SysUtils, FileUtil, Forms,  Controls, ExtCtrls, StdCtrls, ComCtrls, Graphics, Menus,  Grids, Buttons, IniFiles, StrUtils, Printers, OSPrinters, Variants,  lMessages, LCLIntf, LCLProc, LCLType,  fpSpreadsheet, fpsTypes, xlsxOOXML, fpsexport;            Do I need: Process or  ShellApi ?
 ::)

 

lainz:
https://wiki.lazarus.freepascal.org/opendocument

seghele0:
 :)
Thank you.
It's working fine.

seghele0:
 :(
I should have written: works fine in Windows 11.

When I use the program in Linux and open via 'wine' then the function "opendocument" doesn't work.
All the rest of the program still works in Linux with "wine".
 :-[


Zvoni:
I'm not even going to ask, why you run a Lazarus-Program under Wine......

Your call to opendocument fails, BECAUSE you are running it under wine
https://wiki.winehq.org/FAQ#How_do_I_associate_a_native_program_with_a_file_type_in_Wine.3F
You have to associate the default native Linux-Program to the File-Extension in wine

Navigation

[0] Message Index

[#] Next page

Go to full version