5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Jscript/Excel 覚え書き2 - hello world -

Posted at

覚え書き(2)

新規excelファイルをオープンし、A1に「hello world」と記入する。

Rangeを使用
helloworld.js
var objXL = new ActiveXObject("Excel.Application");
objXL.Visible = true;              //Excelを表示する
var book = objXL.Workbooks.Add();  //新規ブック
var sheet = book.Worksheets(1);    //1シート目のオブジェクトを取得

sheet.Range("A1").Value = "hello world";  //Range(A列1行目)

book.SaveAs("Book1.xlsx");  //新規保存(おそらくドキュメントフォルダへ)
book.Close();
objXL.Quit();
Cellsを使用
helloworld.js
var objXL = new ActiveXObject("Excel.Application");
objXL.Visible = true;              //Excelを表示する
var book = objXL.Workbooks.Add();  //新規ブック
var sheet = book.Worksheets(1);    //1シート目のオブジェクトを取得

sheet.Cells(1, 1).Value = "hello world";  //Cells(1行目, 1列目)

book.SaveAs("Book1.xlsx");  //新規保存(おそらくドキュメントフォルダへ)
book.Close();
objXL.Quit();
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?