WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Write Data to an XLS file

You can use the following code to insert data to the XLS file.
; ********************************************************************************
; *
; * Excel OLE Sample
; *
; ********************************************************************************                                                 

row = 1
data = '001,"c:\temp\mydoc.doc",07/01/2003,high,complete'
headinglist = "ID Number,File Name,Date/Time,Priority,Status"
colcount = ItemCount(headinglist,",")

objXL = ObjectOpen("Excel.Application")
objXL.Visible = @TRUE
objWorkbooks=objXL.WorkBooks
objWorkbooks.Add

For column = 1 to colcount
	if column == 1
	   ;Insert Column Headings
		for col = 1 to colcount
	      heading = ItemExtract(col,headinglist,",")
	      objCells=objXL.Cells(1, col)
	      objCells.Value=heading
		next
	endif
	;Insert Row of Data
	field = ItemExtract(column, data,",")
	objCells=objXL.Cells(row+1,column)
	objCells.Value=field
	ObjectClose(objCells)
Next


ObjectClose(objWorkbooks)
ObjectClose(objXL)

Message("WinBatch OLE Sample","Complete")


Article ID:   W16109
File Created: 2004:03:30:15:42:56
Last Updated: 2004:03:30:15:42:56