Lazarus

Free Pascal => Beginners => Topic started by: seghele0 on September 21, 2021, 04:14:21 pm

Title: Save as XLSX file
Post by: seghele0 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.
 ;)
Title: Re: Save as XLSX file
Post by: Zvoni 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?
Title: Re: Save as XLSX file
Post by: seghele0 on September 21, 2021, 05:20:12 pm
Can there be an example, plese.
Title: Re: Save as XLSX file
Post by: wp 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.  
Title: Re: Save as XLSX file
Post by: seghele0 on September 22, 2021, 09:13:01 am
Wp, thank you for the code.
 :)
TinyPortal © 2005-2018