Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon




Login
Register

© winscripter.com
1998-2004







Script: Excel - Create Spreadsheet, Customize and Insert Data

Posted by on Sunday, January 18, 2004 (PST)

Script: Creates and Excel spreadsheet using Excel.Application. Adjusts column width and style. Inserts data.

 

/**
 *    Name:             excelintro.js
 *    Description:      Simple script to demonstrate some of
 *                      the basic operations needed to interact
 *                      with an excel spreadsheet.
 *    Author:           Daren Thiel
 *    Date:             31 Oct 1998
 *    Web:             
http://www.winscripter.com
 **/
/* Create Excel Object */
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();
/* 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";
 



WSH and ADSI Administrative Scripting

New Articles
  • List installed COM objects and associated ProgIDs
    Script: Lists all COM Objects and their associated ProgIDs (If available). Win32_ClassicCOMClassSetting

  • Script: File Rotator
    Script: Rotate files where the most current file has the lowest number in the archive. When files exceed the retention period, they are deleted. Typically used for log files, backups, etc..

  • Script: Create IIS Website and DNS record
    Script: Dan Casier sent me this script that will create a website and appropriate DNS record. The script is intended for Windows 2000 Server with local DNS and necessary DNS mof installed.


  • Winscripter   |  WSH   |  Forums   |  Downloads   |  Books   |  Links   |  Amazon