Hi Emeka,

Am 17.05.2009 um 21:59 schrieb janus:

I can't figure out how to read cells with Jacob. I need a help.

I'm totally sorry. I forgot to answer your pm. :|

This is the example you quoted. And there you already have
the solution.

(import '(com.jacob.com Dispatch ComThread))

(def xl (new Dispatch "Excel.Application"))
Start Excel.

(def wbl (.. Dispatch (get xl "Workbooks") (toDispatch)))
Get the Workbooks collection.

(def wb (.. Dispatch (call wbl "Add") (toDispatch)))
Add a new Workbook.

(def wsl (.. Dispatch (get wb "Worksheets") (toDispatch)))
Get the Worksheets collection of the new Workbook.

(def ws (.. Dispatch (call wsl "Item" 1) (toDispatch)))
Get the first Worksheet. (Probably "Sheet1")

(def c (.. Dispatch (call ws "Cells" 1 1) (toDispatch)))
Here you retrieve the actual cell.

(. Dispatch put c "Value" "Hello, World!")
Write "Hello, World!" into the cell.

(. Dispatch call wb "SaveAs" "Hello.xls")
Save the Workbook...

(. Dispatch call wb "Close" false)
... and close it.

(. Dispatch call xl "Quit")
Close Excel.

(. ComThread Release)
And make sure it's really stopped.

Hope that helps.

Sincerely
Meikel

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to