Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ExcelSheet question
#5
You can start Excel invisible, and open the file:

Code:
Copy      Help
str sfile="$personal$\book1.xls"
str ssheet="Sheet2"

Excel.Application app._create
;app.Visible=TRUE ;;uncomment to make Excel visible
Excel.Workbook book=app.Workbooks.Open(_s.expandpath(sfile))
ExcelSheet es.ws=book.Worksheets.Item(ssheet)

;now you can get/set cells using es
str s
es.GetCell(s 2 2)
out s
es.SetCell("newvalue" 2 2)

book.Save
app.Quit

The problem is that, if an error occurs, app.Quit is not executed, and Excel does not exit, and you'll have to end EXCEL process in Task Manager. To solve this problem, use this instead:

Code:
Copy      Help
str sfile="$personal$\book1.xls"
str ssheet="Sheet2"

Excel.Application app._create
atend ExcelQuit &app
;app.Visible=TRUE ;;uncomment to make Excel visible
Excel.Workbook book=app.Workbooks.Open(_s.expandpath(sfile))
ExcelSheet es.ws=book.Worksheets.Item(ssheet)

;now you can get/set cells using es
str s
es.GetCell(s 2 2)
out s
es.SetCell("newvalue" 2 2)

book.Save

Function ExcelQuit
Code:
Copy      Help
function Excel.Application*a
a.Quit


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)