Created
November 26, 2018 12:54
-
-
Save TeraokaAkihiro/e0f2270e94f32ced4e805a2dad386a34 to your computer and use it in GitHub Desktop.
JScriptでExcelファイルを編集する ref: https://qiita.com/Teaki/items/39d8333e4c8ddb6950fa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("シート名"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cells(行, 列) | |
WS.Cells(1,1).Value = 1; | |
// 日付は/区切りで | |
WS.Cells(1,1).Value = "2018/11/26"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 背景色を黄色に | |
WS.Cells(1,1).Interior.Color = ConvertRGB(255, 255, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 四方に普通の線を引く | |
WS.Cells(1,1).Borders.LineStyle = 1; | |
// 下にドットを引く | |
WS.Cells(1,1).Borders(9).LineStyle = -4118; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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