Recent

Author Topic: Save as XLSX file  (Read 744 times)

seghele0

  • Jr. Member
  • **
  • Posts: 84
Save as XLSX file
« on: September 21, 2021, 04:14:21 pm »
Would like to have a name and date in the file name.

Code: Pascal  [Select][+][-]
  1. workbook.WriteToFile('Wiezen.xlsx', sfOOXML, true);

Result: Wiezen-21092021.xlsx
(ddmmyyyy)

Thanks.
 ;)

Zvoni

  • Hero Member
  • *****
  • Posts: 808
Re: Save as XLSX file
« Reply #1 on: September 21, 2021, 04:22:58 pm »
Huh?
Use the Date-Function? https://www.freepascal.org/docs-html/rtl/sysutils/date.html
and build your filename by concatenating everything together?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

seghele0

  • Jr. Member
  • **
  • Posts: 84
Re: Save as XLSX file
« Reply #2 on: September 21, 2021, 05:20:12 pm »
Can there be an example, plese.

wp

  • Hero Member
  • *****
  • Posts: 9034
Re: Save as XLSX file
« Reply #3 on: September 21, 2021, 05:37:18 pm »
Code: Pascal  [Select][+][-]
  1. var
  2.   filename: String;
  3. ...
  4.   filename := 'Wiezen-' + FormatDateTime('ddmmyyyy', Date);
  5. // or even:
  6. //  filename := FormatDateTime('"Wiezen-"ddmmyyyy', Date);
  7.   workbook.WriteToFile(filename, sfOOXML, true);
  8.  
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

seghele0

  • Jr. Member
  • **
  • Posts: 84
Re: Save as XLSX file
« Reply #4 on: September 22, 2021, 09:13:01 am »
Wp, thank you for the code.
 :)

 

TinyPortal © 2005-2018