d

Excel Simple

How to:

/* Create Excel Object */
var objXL = WScript.CreateObject("Excel.Application");

/* Show it to the user */
objXL.Visible = true;

/* Add a workbook */
objXL.WorkBooks.Add();

/* Add a worksheet */
objXL.Sheets.Add();
objXL.Sheets.Add();
objXL.Sheets.Add(); 
objXL.Sheets.Add();

/* Resize a couple of columns on sheet1 */
objXL.Sheets("Sheet1").Select();
objXL.Columns(1).ColumnWidth = 40;
objXL.Columns(2).ColumnWidth = 20;

/* Rename the sheet to WSH Test */
objXL.Sheets("Sheet1").Select();
objXL.Sheets("Sheet1").Name = "WSH Test";

/* Change the background color of header cells */
objXL.Cells(1, 1).Select();
objXL.Selection.Interior.ColorIndex = 40;
objXL.Cells(1, 2).Select();
objXL.Selection.Interior.ColorIndex = 40;

/* Insert Data into cells */
objXL.Cells(1, 1).Value = "Name";
objXL.Cells(1, 2).Value = "Phone";
objXL.Cells(2, 1).Value = "Blow, Joe";
objXL.Cells(2, 2).Value = "555-5555";
objXL.Cells(3, 1).Value = "Smith, John";
objXL.Cells(3, 2).Value = "555-1212";