Skip to content

Instantly share code, notes, and snippets.

@TeraokaAkihiro
Created November 26, 2018 12:54
Show Gist options
  • Save TeraokaAkihiro/e0f2270e94f32ced4e805a2dad386a34 to your computer and use it in GitHub Desktop.
Save TeraokaAkihiro/e0f2270e94f32ced4e805a2dad386a34 to your computer and use it in GitHub Desktop.
JScriptでExcelファイルを編集する ref: https://qiita.com/Teaki/items/39d8333e4c8ddb6950fa
var ExcelApp = new ActiveXObject("Excel.Application");
ExcelApp.Visible = true;
ExcelApp.DisplayAlerts = false;
var WB = ExcelApp.Workbooks.Open("[Excelファイルのパス]");
var WS = WB.Worksheets(1);
WS = WB.Worksheets("シート名");
// Cells(行, 列)
WS.Cells(1,1).Value = 1;
// 日付は/区切りで
WS.Cells(1,1).Value = "2018/11/26";
// BGRで指定
var red = parseInt("0000FF", 16);
// RGBから変換
function Convert_RGB(r, g, b){
var color;
color += r;
color += g << 8;
color += b << 16;
return color;
}
// 背景色を黄色に
WS.Cells(1,1).Interior.Color = ConvertRGB(255, 255, 0);
// 四方に普通の線を引く
WS.Cells(1,1).Borders.LineStyle = 1;
// 下にドットを引く
WS.Cells(1,1).Borders(9).LineStyle = -4118;
var r = Convert_RGB(255, 0, 0);
var g = Convert_RGB( 0, 255, 0);
var b = Convert_RGB( 0, 0, 255);
var colors = [r,g,b];
for (var i=0; i < 15; i++) {
WS.Cells(1,i+1).Interior.Color = colors[i % 3];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment