{"id":11839,"date":"2019-07-17T09:29:41","date_gmt":"2019-07-17T00:29:41","guid":{"rendered":"https:\/\/elleneast.com\/?p=11839"},"modified":"2019-08-22T20:10:06","modified_gmt":"2019-08-22T11:10:06","slug":"%e3%80%90vb-net%e3%80%91closedxml%ef%bc%9a%e3%83%87%e3%83%bc%e3%82%bf%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/elleneast.com\/?p=11839","title":{"rendered":"\u3010VB.NET\u3011ClosedXML\uff1a\u30c7\u30fc\u30bf\u578b"},"content":{"rendered":"[include-page id=\u201d11760\u2033]\n<p>\u30b3\u30fc\u30c9<\/p>\n<pre class=\"lang:vbnet decode:true \">Dim workbook = New XLWorkbook\nDim ws = workbook.Worksheets.Add(\"\u30c7\u30fc\u30bf\u578b\")\n\nDim co = 2\nDim ro = 1\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\uff1a\"\nws.Cell(ro, co + 1).Value = \"Hello World.\"\n\nro += 1\nws.Cell(ro, co).Value = \"\u65e5\u4ed8\uff1a\"\nws.Cell(ro, co + 1).Value = New DateTime(2010, 9, 2)\n\nro += 1\nws.Cell(ro, co).Value = \"\u65e5\u6642\uff1a\"\nws.Cell(ro, co + 1).Value = New DateTime(2010, 9, 2, 13, 45, 22)\n\nro += 1\nws.Cell(ro, co).Value = \"\u30d6\u30fc\u30eb\uff1a\"\nws.Cell(ro, co + 1).Value = True\n\nro += 1\nws.Cell(ro, co).Value = \"\u6570\u5024\uff1a\"\nws.Cell(ro, co + 1).Value = 123.45\n\nro += 1\nws.Cell(ro, co).Value = \"\u30bf\u30a4\u30e0\u30b9\u30d1\u30f3\uff1a\"\nws.Cell(ro, co + 1).Value = New TimeSpan(33, 45, 22)\n\nro += 1\n\nro += 1\nws.Cell(ro, co).Value = \"\u660e\u793a\u7684\u30c6\u30ad\u30b9\u30c8\uff1a\"\nws.Cell(ro, co + 1).Value = \"'Hello World.\"\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\u3068\u3057\u3066\u5165\u529b\u3057\u305f\u65e5\u4ed8\uff1a\"\nws.Cell(ro, co + 1).Value = \"'\" + New DateTime(2010, 9, 2).ToString\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\u3068\u3057\u3066\u5165\u529b\u3057\u305f\u65e5\u6642\uff1a\"\nws.Cell(ro, co + 1).Value = \"'\" + New DateTime(2010, 9, 2, 13, 45, 22).ToString\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\u3068\u3057\u3066\u5165\u529b\u3057\u305f\u30d6\u30fc\u30eb\uff1a\"\nws.Cell(ro, co + 1).Value = \"'\" + True.ToString\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\u3068\u3057\u3066\u5165\u529b\u3057\u305f\u6570\u5024\uff1a\"\nws.Cell(ro, co + 1).Value = \"'123.45\"\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\u3068\u3057\u3066\u5165\u529b\u3057\u305f\u30bf\u30a4\u30e0\u30b9\u30d1\u30f3\uff1a\"\nws.Cell(ro, co + 1).Value = \"'\" + New TimeSpan(33, 45, 22).ToString\n\nro += 1\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c7\u30fc\u30bf\u578b\u306e\u5909\u66f4\uff1a\"\n\nro += 1\n\nro += 1\nws.Cell(ro, co).Value = \"\u65e5\u4ed8\u304b\u3089\u30c6\u30ad\u30b9\u30c8\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = New DateTime(2010, 9, 2)\nws.Cell(ro, co + 1).DataType = XLDataType.Text\n'\u5143\u8a18\u4e8b\u306e XLCellValues \u306f ClosedXML \u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3067 XLDataType \u306b\u5909\u66f4\u3055\u308c\u305f\uff08by \u30a8\u30ec\u30f3\u30fb\u30a4\u30fc\u30b9\u30c8\uff09\n\nro += 1\nws.Cell(ro, co).Value = \"\u65e5\u6642\u304b\u3089\u30c6\u30ad\u30b9\u30c8\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = New DateTime(2010, 9, 2, 13, 45, 22)\nws.Cell(ro, co + 1).DataType = XLDataType.Text\n\nro += 1\nws.Cell(ro, co).Value = \"\u30d6\u30fc\u30eb\u304b\u3089\u30c6\u30ad\u30b9\u30c8\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = True\nws.Cell(ro, co + 1).DataType = XLDataType.Text\n\nro += 1\nws.Cell(ro, co).Value = \"\u6570\u5024\u304b\u3089\u30c6\u30ad\u30b9\u30c8\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = 123.45\nws.Cell(ro, co + 1).DataType = XLDataType.Text\n\nro += 1\nws.Cell(ro, co).Value = \"\u30bf\u30a4\u30e0\u30b9\u30d1\u30f3\u304b\u3089\u30c6\u30ad\u30b9\u30c8\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = New TimeSpan(33, 45, 22)\nws.Cell(ro, co + 1).DataType = XLDataType.Text\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\u304b\u3089\u65e5\u4ed8\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = \"'\" + New DateTime(2010, 9, 2).ToString\nws.Cell(ro, co + 1).DataType = XLDataType.DateTime\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\u304b\u3089\u65e5\u6642\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = \"'\" + New DateTime(2010, 9, 2, 13, 45, 22).ToString\nws.Cell(ro, co + 1).DataType = XLDataType.DateTime\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\u304b\u3089\u30d6\u30fc\u30eb\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = \"'\" + True.ToString\nws.Cell(ro, co + 1).DataType = XLDataType.Boolean\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\u304b\u3089\u6570\u5024\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = \"'123.45\"\nws.Cell(ro, co + 1).DataType = XLDataType.Number\n\nro += 1\nws.Cell(ro, co).Value = \"\u30c6\u30ad\u30b9\u30c8\u304b\u3089\u30bf\u30a4\u30e0\u30b9\u30d1\u30f3\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = \"'\" + New TimeSpan(33, 45, 22).ToString\nws.Cell(ro, co + 1).DataType = XLDataType.TimeSpan\n\nro += 1\n\nro += 1\nws.Cell(ro, co).Value = \"\u66f8\u5f0f\u6307\u5b9a\u3055\u308c\u305f\u65e5\u4ed8\u304b\u3089\u30c6\u30ad\u30b9\u30c8\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = New DateTime(2010, 9, 2)\nws.Cell(ro, co + 1).Style.DateFormat.Format = \"yyyy-MM-dd\"\nws.Cell(ro, co + 1).DataType = XLDataType.Text\n\nro += 1\nws.Cell(ro, co).Value = \"\u66f8\u5f0f\u6307\u5b9a\u3055\u308c\u305f\u6570\u5024\u304b\u3089\u30c6\u30ad\u30b9\u30c8\u3078\uff1a\"\nws.Cell(ro, co + 1).Value = 12345.6789\nws.Cell(ro, co + 1).Style.NumberFormat.Format = \"#,##0.00\"\nws.Cell(ro, co + 1).DataType = XLDataType.Text\n\nro += 1\n\nro += 1\nws.Cell(ro, co).Value = \"\u7a7a\u306e\u30c6\u30ad\u30b9\u30c8\uff1a\"\nws.Cell(ro, co + 1).Value = 12345.6789\nws.Cell(ro, co + 1).Style.NumberFormat.Format = \"#,##0.00\"\nws.Cell(ro, co + 1).DataType = XLDataType.Text\nws.Cell(ro, co + 1).Value = \"\"\n\nro += 1\n\n'\u30a4\u30f3\u30e9\u30a4\u30f3\u6587\u5b57\u5217\u306e\u4f7f\u7528\uff08\u307b\u3068\u3093\u3069\u306e\u30e6\u30fc\u30b6\u30fc\u306b\u306f\u4e0d\u8981\u306a\u6a5f\u80fd\uff09\n'\n'\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001\u3059\u3079\u3066\u306e\u30bb\u30eb\u5185\u306e\u6587\u5b57\u5217\u306f\u8907\u6570\u306e\u30bb\u30eb\u304b\u3089\n'\u53c2\u7167\uff08\u5171\u6709\uff09\u3067\u304d\u308b\u3088\u3046\u306b\u4fdd\u5b58\u3055\u308c\u307e\u3059\u3002\n'\uff08\u8907\u6570\u306e\u30bb\u30eb\u304c\u540c\u4e00\u306e\u30c6\u30ad\u30b9\u30c8\u3092\u542b\u3080\u3068\u304d\u3001\u305d\u306e\u30bb\u30eb\u306e\u6570\u3060\u3051\n'\u30c6\u30ad\u30b9\u30c8\u3092\u4fdd\u5b58\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\uff11\u3064\u306e\u30c6\u30ad\u30b9\u30c8\u306e\u307f\u3092\n'\u4fdd\u5b58\u3057\u3066\u8907\u6570\u306e\u30bb\u30eb\u304b\u3089\u305d\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u53c2\u7167\u3059\u308b\uff09\n'.ShareString \u30d7\u30ed\u30d1\u30c6\u30a3\u306b False \u3092\u8a2d\u5b9a\u3059\u308b\u3068\u3053\u306e\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3067\u304d\u307e\u3059\u3002\nro += 1\nws.Cell(ro, co).Value = \"\u30a4\u30f3\u30e9\u30a4\u30f3\u6587\u5b57\u5217\uff1a\"\nDim cell = ws.Cell(ro, co + 1)\ncell.Value = \"\u975e\u5171\u6709\"\ncell.ShareString = False\n\n'\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u306e\u3059\u3079\u3066\u306e\u5171\u6709\u6587\u5b57\u5217\u3092\u53c2\u7167\u3059\u308b\u306b\u306f\u6b21\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\n'workbook.GetSharedStrings\n'ClosedXML 0.94.2 \u306b\u304a\u3044\u3066\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u7121\u52b9\u306e\u3088\u3046\u3067\u3059\u3002by \u30a8\u30ec\u30f3\u30fb\u30a4\u30fc\u30b9\u30c8\n\n'\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\u65e5\u672c\u8a9e\u306e\u5834\u5408\u306f\u65e5\u672c\u8a9e\u30d5\u30a9\u30f3\u30c8\u306b\u3057\u3066\u304a\u304b\u306a\u3044\u3068 AdjustToContents \u304c\u6b63\u3057\u304f\u52d5\u4f5c\u3057\u306a\u3044\nws.Style.Font.FontName = \"\u6e38\u30b4\u30b7\u30c3\u30af\";\nws.Columns(2, 3).AdjustToContents\n\nworkbook.SaveAs(\"D:\\test\\DataTypes.xlsx\")<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5b9f\u884c\u7d50\u679c<\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_08.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11841 bigshadow\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_08.png\" alt=\"\" width=\"493\" height=\"716\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_08.png 493w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_08-207x300.png 207w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/elleneast.com\/?cat=90\">\u300c\u3010VB.NET\u3011ClosedXML \u306e\u4f7f\u3044\u65b9\u300d\u306e\u4e00\u89a7\u3092\u8868\u793a<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[include-page id=\u201d11760\u2033] \u30b3\u30fc\u30c9 Dim workbook = New XLWorkbook Dim ws = workbook.Worksheets.Add(&#8220;\u30c7\u30fc\u30bf\u578b&#8221;) Dim co =  &#8230; <\/p>\n","protected":false},"author":1,"featured_media":2656,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[90],"tags":[],"class_list":{"0":"post-11839","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-closedxml"},"_links":{"self":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/11839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11839"}],"version-history":[{"count":3,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/11839\/revisions"}],"predecessor-version":[{"id":12965,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/11839\/revisions\/12965"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/media\/2656"}],"wp:attachment":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}