Specifying cells in excel using TCOM

The command $cells Item 2 A {SomeText} doesn't set the text in the cell A2 instead it assigns the text in the cell A1. Any idea on why its behaving like this???

              set application [::tcom::ref createobject "Excel.Application"]
              set XlFileFormat(xlCSV) [expr 6]
              set workbooks [$application Workbooks]
              set workbook [$workbooks Add]
              $application DisplayAlerts False
              set worksheets [$workbook Worksheets]
              set worksheet [$worksheets Item [expr 1]]
              set cells [$worksheet Cells]
            $cells Item 2 A {Range}


              $workbook SaveAs {c:\test.csv} $XlFileFormat(xlCSV)      
              $application Quit

Answers


Okay, here's an explanation: when saving to CSV, Excel seems to save just the data which form the "bounding box" inside the (virtualized) sheet grid. In other words, you have not modified any data in the cells of the first row, and hence it's not saved.

This simple program (JScript for WSH):

var app = new ActiveXObject("Excel.Application");
var wbs = app.Workbooks;
var wb  = wbs.Add;
var wss = wb.Worksheets;
var ws  = wss.Item(1);
var cells = ws.Cells;

app.DisplayAlerts = false;

cells.Item(2, "B") = "B2";
cells.Item(2, "C") = "C2";
cells.Item(3, "B") = "B3";
cells.Item(3, "C") = "C3";

wb.SaveAs("foo.csv", 6);
app.Quit();

which sets four cells arranged in a rectangular block offset by one column and one row from the top-left corner of the sheet, produces this CSV file:

B2,C2
B3,C3

Need Your Help

jQuery Scroll Down button used to scroll page by 100%

jquery html css button scroll

I am making a website and having trouble with a button that uses jQuery to scroll the page down by 100%. I'm having trouble because it scrolls different spaces between browsers and window sizes. Any

display featured image in post - wordpress theme

php wordpress themes wordpress-theming

I have installed wordpress on my local wampp server. The question refers to the default theme that comes with wordpress after the first install(twentytwelve).