Welcome! Log In Create A New Profile

Advanced

[WB2025] - Creating an XLS file

Posted by JP 
JP
[WB2025] - Creating an XLS file
December 22, 2025 02:09PM
Hi All

Using WebDev 2025.

I want to create an Excel file on the server and populate it with some data. Then return it to the user's browser. I am not clear on how to do this because I cannot see a function for writing data into specific cells of the Excel file. I see there is a function to open an Excel file XLSOpen() and a function to read data from a cell XLSData(), but what function is used to send data to specific cells?

Or are there better ways to create an XLS file and put data into it?

TIA



Edited 1 time(s). Last edit at 12/22/2025 02:10PM by JP.
Re: [WB2025] - Creating an XLS file
December 22, 2025 09:41PM
Hello JP.
Maybe some of my code here can help you do what you want.

sTempFile is string
xlsDoc is xlsDocument
docExcel is xlsDocument
nred, ncol, nRedniBroj is int
cySuma is currency

xlsAddWorksheet(docExcel, "MyList", 1)
docExcel..Worksheet = 1

nred = 1

FOR i = 1 TO 5
docExcel..Column..Width = 170
docExcel..Row[nred]..Cell..Font..Name = "Calibri (body)"
docExcel..Row[nred]..Cell..Font..Bold = True
docExcel..Row[nred]..Cell..Font..Size = 11
docExcel..Row[nred]..Cell..Font..Color = Black
END
docExcel..Row[nred]..Cell[1]..AlignmentH = haCenter
docExcel..Row[nred]..Cell[1] = "JMBG"
docExcel..Row[nred]..Cell[2]..AlignmentH = haCenter
docExcel..Row[nred]..Cell[2] = "Surename"
docExcel..Row[nred]..Cell[3]..AlignmentH = haCenter
docExcel..Row[nred]..Cell[3] = "Name"
docExcel..Row[nred]..Cell[4]..AlignmentH = haCenter
docExcel..Row[nred]..Cell[4] = "Credit"
docExcel..Row[nred]..Cell[5]..AlignmentH = haRight
docExcel..Row[nred]..Cell[5] = "Amount"

MyTable.ReadFirst()
WHILE MyTable.Out() = False
nred +=1
cySuma +=MyTable.SomeAmountField
docExcel[nred,1] = MyTable.SomeField1
docExcel[nred,2] = MyTable.SomeField2
docExcel[nred,3] = MyTable.SomeField3
docExcel[nred,4] = MyTable.SomeField4
docExcel[nred,5]..AlignmentH = haRight
docExcel[nred,5]..Mask = "0.00"
docExcel[nred,5] = MyTable.SomeField5

MyTable.ReadNext()
nred +=1
END
docExcel[nred+1,3] = "TOTAL"
docExcel[nred+1,5]..AlignmentH = haRight
docExcel[nred+1,5]..Mask = "0.00"
docExcel[nred+1,5] = cySuma

// Save the file
sTempFile = "MyList.xlsx"
xlsSave(docExcel, sTempFile)
xlsClose(docExcel)
JP
Re: [WB2025] - Creating an XLS file
December 23, 2025 03:04PM
Thanks Ismir, I will give that a try.

Thanks!

JP
JP
Re: [WB2025] - Creating an XLS file
December 24, 2025 03:20PM
Thanks Ismir, I got it all working with your suggested code samples.
Re: [WB2025] - Creating an XLS file
December 25, 2025 09:45PM
Glad to hear that, JP. I wish you a nice day and Merry Christmas to everyone celebrating!
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: