LoginSignup
0
0

cscの作法 その342

Posted at

概要

cscの作法、調べてみた。
練習問題、やってみた。

練習問題

closedxmlでasciiなxlsxを作れ。

写真

image.png

サンプルコード


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), "Book7.xlsx");
			var wb = new XLWorkbook();
			var ws = wb.Worksheets.Add("Sheet1");
			int i;
			int j;
			byte b = 31;
			for (i = 0; i < 16; i++)
			{
				ws.Cell(1, i + 2).Value = i.ToString();
				ws.Cell(1, i + 2).Style.Fill.BackgroundColor = XLColor.Aqua;
			}
			for (i = 0; i < 6; i++)
			{
				ws.Cell(i + 2, 1).Value = (i * 16 + 32).ToString();
				ws.Cell(i + 2, 1).Style.Fill.BackgroundColor = XLColor.Aqua;
			}
			for (i = 0; i < 6; i++)
			{
				for (j = 0; j < 16; j++)
				{
					b++;
					char c2 = Convert.ToChar(b);
					ws.Cell(i + 2, j + 2).Value = c2;
				}
			}
			wb.SaveAs(filePath);
			Console.WriteLine("ok");
		}
	}
}





以上。

0
0
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
0
0