Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutoIT Create New, valid Excel File

How do I create a new, valid Excel file in Autoit?

Local $sFileName = @ScriptDir & "\Worksheet.xls"
Local $oExcel = _Excel_BookNew($sFileName, 10)

creates an invalid one with 0 Bytes, which I cannot open.

like image 392
HausUkrop Avatar asked Dec 01 '25 02:12

HausUkrop


1 Answers

You first have to open Excel, then create the new book, save the book and finally close Excel again.

#include <Excel.au3>
#include <MsgBoxConstants.au3>

Local $FilePath = @ScriptDir & "\Worksheet.xls"

Local $oExcel = _Excel_Open(False, Default, Default, Default, True)
Local $oBook = _Excel_BookNew($oExcel, 1)
_Excel_BookSaveAs($oBook, $FilePath)
_Excel_Close($oExcel, True)

Source:

https://www.autoitscript.com/autoit3/docs/libfunctions/_Excel_Open.htm https://www.autoitscript.com/autoit3/docs/libfunctions/_Excel_BookNew.htm https://www.autoitscript.com/autoit3/docs/libfunctions/_Excel_BookSave.htm

Tipp:

Just google the commands and interpret the exampels.

like image 81
IkeRoyle Avatar answered Dec 05 '25 15:12

IkeRoyle