概要
cscの作法、調べてみた。
練習問題やってみた。
練習問題
closedxmlで、テンプレートに書き込め。
写真
サンプルコード
using System;
using System.IO;
using ClosedXML.Excel;
namespace App
{
class Program {
static void Main(string[] args) {
var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Book3.xlsx");
var wb = new XLWorkbook("red.xlsx");
IXLWorksheet sheet1;
if (wb.TryGetWorksheet("Sheet1", out sheet1))
{
Console.WriteLine(sheet1.Name);
}
else
{
Console.WriteLine("ワークシートを取得できませんでした。");
}
sheet1.Cell("b5").Value = "相田株式会社";
sheet1.Cell("b7").Value = "開発部御中";
sheet1.Cell("b18").Value = "サーベル";
sheet1.Cell("e18").Value = "1";
sheet1.Cell("f18").Value = "本";
sheet1.Cell("g18").Value = "12500";
wb.SaveAs(filePath);
Console.WriteLine("ok");
}
}
}
以上。