{"id":11952,"date":"2019-07-17T09:22:51","date_gmt":"2019-07-17T00:22:51","guid":{"rendered":"https:\/\/elleneast.com\/?p=11952"},"modified":"2019-08-22T19:29:20","modified_gmt":"2019-08-22T10:29:20","slug":"%e3%80%90vb-net%e3%80%91closedxml%ef%bc%9a%e3%83%94%e3%83%9c%e3%83%83%e3%83%88%e3%83%86%e3%83%bc%e3%83%96%e3%83%ab","status":"publish","type":"post","link":"https:\/\/elleneast.com\/?p=11952","title":{"rendered":"\u3010VB.NET\u3011ClosedXML\uff1a\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb"},"content":{"rendered":"[include-page id=\u201d11760\u2033]\n<\/p>\n<div class=\"memo alert\">\n<div class=\"memo_ttl dfont\"> \u6ce8\u610f<\/div>\n<p>\u5143\u8a18\u4e8b\uff082018\u5e744\u670825\u65e5\u4ed8\uff09\u306b\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002by \u30a8\u30ec\u30f3\u30fb\u30a4\u30fc\u30b9\u30c8\uff08\u5f53\u30b5\u30a4\u30c8\u306e\u7ba1\u7406\u4eba\uff09<\/p>\n<blockquote class=\"quote_silver\">\n<p>\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\u306e\u30b5\u30dd\u30fc\u30c8\u306f\u307e\u3060\u304b\u306a\u308a\u5b9f\u9a13\u7684\u306a\u6bb5\u968e\u3067\u3059\u3002<br \/>\nPivot table support is still very experimental.<\/p>\n<\/blockquote>\n<\/div>\n<p>&nbsp;<\/p>\n<p>\u6708\u3054\u3068\u306e\u83d3\u5b50\u30d1\u30f3\u306e\u58f2\u308a\u4e0a\u3052\u3092\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\u306b\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001\u83d3\u5b50\u30d1\u30f3 (Pastry) \u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vbnet decode:true \">Public Class Pastry\n    '\u30d7\u30ed\u30d1\u30c6\u30a3\u540d\u304c\u30c6\u30fc\u30d6\u30eb\u306e\u5217\u30bf\u30a4\u30c8\u30eb\u306b\u4f7f\u308f\u308c\u308b\n    Public Property \u540d\u79f0 As String\n    Public Property \u6ce8\u6587\u6570 As Integer\n    Public Property \u6708 As String\n\n    Public Sub New(name As String, amount As Integer, month As Integer)\n        Me.\u540d\u79f0 = name\n        Me.\u6708 = month &amp; \"\u6708\"\n        Me.\u6ce8\u6587\u6570 = amount\n    End Sub\nEnd Class<\/pre>\n<p>\u6b21\u306b Pastry \u30af\u30e9\u30b9\u3092\u4f7f\u7528\u3057\u3066\u58f2\u308a\u4e0a\u3052\u30c7\u30fc\u30bf\u306e\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vbnet decode:true \">Dim pastries = New List(Of Pastry) From\n{\n  New Pastry(\"\u30af\u30ed\u30ef\u30c3\u30b5\u30f3\", 150, 4),\n  New Pastry(\"\u30af\u30ed\u30ef\u30c3\u30b5\u30f3\", 250, 5),\n  New Pastry(\"\u30af\u30ed\u30ef\u30c3\u30b5\u30f3\", 134, 6),\n  New Pastry(\"\u30c9\u30fc\u30ca\u30c4\", 250, 4),\n  New Pastry(\"\u30c9\u30fc\u30ca\u30c4\", 225, 5),\n  New Pastry(\"\u30c9\u30fc\u30ca\u30c4\", 210, 6),\n  New Pastry(\"\u30d9\u30a2\u30af\u30ed\u30a6\", 134, 4),\n  New Pastry(\"\u30d9\u30a2\u30af\u30ed\u30a6\", 184, 5),\n  New Pastry(\"\u30d9\u30a2\u30af\u30ed\u30a6\", 124, 6),\n  New Pastry(\"\u30c7\u30cb\u30c3\u30b7\u30e5\", 394, 4),\n  New Pastry(\"\u30c7\u30cb\u30c3\u30b7\u30e5\", 190, 5),\n  New Pastry(\"\u30c7\u30cb\u30c3\u30b7\u30e5\", 221, 6),\n  New Pastry(\"\u30b9\u30b3\u30fc\u30f3\", 135, 4),\n  New Pastry(\"\u30b9\u30b3\u30fc\u30f3\", 122, 5),\n  New Pastry(\"\u30b9\u30b3\u30fc\u30f3\", 243, 6)\n}<\/pre>\n<p>\u4f5c\u6210\u3057\u305f\u30ea\u30b9\u30c8\u3092\u30c6\u30fc\u30d6\u30eb\u3068\u3057\u3066\u65b0\u898f\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306b\u633f\u5165\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vbnet decode:true \">Dim workbook = New XLWorkbook\nDim sheet = workbook.Worksheets.Add(\"\u83d3\u5b50\u30d1\u30f3\u306e\u58f2\u308a\u4e0a\u3052\u30c7\u30fc\u30bf\")\n\n'\u300c\u83d3\u5b50\u30d1\u30f3\u306e\u58f2\u308a\u4e0a\u3052\u30c7\u30fc\u30bf\u300d\u30b7\u30fc\u30c8\u306e Cel(1, 1) \u306b\u83d3\u5b50\u30d1\u30f3\u30c7\u30fc\u30bf\u306e\u30ea\u30b9\u30c8\u3092\u633f\u5165\nDim table = sheet.Cell(1, 1).InsertTable(pastries, \"\u83d3\u5b50\u30d1\u30f3\u306e\u58f2\u308a\u4e0a\u3052\u30c7\u30fc\u30bf\", True)\n\n'\u5217\u5e45\n'sheet.Columns.AdjustToContents '\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\u6b63\u3057\u304f\u52d5\u4f5c\u3057\u306a\u3044\nsheet.Column(1).Width = 15.5\nsheet.Column(2).Width = 10\nsheet.Column(3).Width = 7\n'\u300c\u6708\u300d\u306e\u5217\u3092\u53f3\u5bc4\u305b\uff08\u30bf\u30a4\u30c8\u30eb\u884c\u4ee5\u5916\uff09\nsheet.Range(sheet.Cell(2, 3), sheet.Column(3).LastCellUsed) _\n    .Style.Alignment.Horizontal=XLAlignmentHorizontalValues.Right<\/pre>\n<p>\u6700\u5f8c\u306b\u3001\u305d\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u30bd\u30fc\u30b9\u3068\u3057\u3066\u3001\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vbnet decode:true\">'\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\u7528\u306e\u65b0\u898f\u30b7\u30fc\u30c8\u3092\u8ffd\u52a0\nDim ptSheet = workbook.Worksheets.Add(\"\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\")\n\n'\u300c\u83d3\u5b50\u30d1\u30f3\u306e\u58f2\u308a\u4e0a\u3052\u30c7\u30fc\u30bf\u300d\u30c6\u30fc\u30d6\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3059\u308b\nDim pt = ptSheet.PivotTables.AddNew(\"\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\", ptSheet.Cell(1, 1), table.AsRange)\n\n'\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\u306e\u884c\u898b\u51fa\u3057\u304c\u83d3\u5b50\u30d1\u30f3\u306e\u540d\u79f0\u306b\u306a\u308a\u307e\u3059\npt.RowLabels.Add(\"\u540d\u79f0\") '\u30d7\u30ed\u30d1\u30c6\u30a3\u540d\u3068\u7570\u306a\u308b\u3068\u30a8\u30e9\u30fc\n\n'\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\u306e\u5217\u898b\u51fa\u3057\u304c\u6708\u306b\u306a\u308a\u307e\u3059\npt.ColumnLabels.Add(\"\u6708\") '\u30d7\u30ed\u30d1\u30c6\u30a3\u540d\u3068\u7570\u306a\u308b\u3068\u30a8\u30e9\u30fc\n\n'\u6ce8\u6587\u6570\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u5024\u304c\u30c6\u30fc\u30d6\u30eb\u306e\u4e2d\u8eab\u306e\u5024\u306b\u306a\u308a\u307e\u3059\u3002\n'\u5404\u884c\u3068\u5217\u306e\u5408\u8a08\u304c\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u8a08\u7b97\u65b9\u6cd5\u3067\u3059\npt.Values.Add(\"\u6ce8\u6587\u6570\") '\u30d7\u30d7\u30ed\u30d1\u30c6\u30a3\u540d\u3068\u7570\u306a\u308b\u3068\u30a8\u30e9\u30fc\n\n'\u5217\u5e45\n'ptSheet.Columns.AdjustToContents '\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\u6b63\u3057\u304f\u52d5\u4f5c\u3057\u306a\u3044\nptSheet.Column(1).Width = 15.5\nptSheet.Column(2).Width = 15.5\nptSheet.Column(3).Width = 7\nptSheet.Column(4).Width = 7\nptSheet.Column(5).Width = 7\n\nworkbook.SaveAs(\"D:\\test\\pivotTable.xlsx\")<\/pre>\n<p>\u4e0b\u56f3\u306e\u3088\u3046\u306a\u30c7\u30fc\u30bf\u30c6\u30fc\u30d6\u30eb\u3068\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_30.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11956 bigshadow\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_30.png\" alt=\"\" width=\"387\" height=\"417\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_30.png 387w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_30-278x300.png 278w\" sizes=\"auto, (max-width: 387px) 100vw, 387px\"><\/a><\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11957 bigshadow\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_31.png\" alt=\"\" width=\"1093\" height=\"459\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_31.png 1093w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_31-300x126.png 300w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_31-768x323.png 768w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_31-1024x430.png 1024w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_31-940x395.png 940w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\"><\/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] &nbsp; \u6708\u3054\u3068\u306e\u83d3\u5b50\u30d1\u30f3\u306e\u58f2\u308a\u4e0a\u3052\u3092\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\u306b\u3057\u3066\u307f\u307e\u3059\u3002 \u307e\u305a\u3001\u83d3\u5b50\u30d1\u30f3 (Pastry) \u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 Public Class Pastry &#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-11952","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\/11952","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=11952"}],"version-history":[{"count":3,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/11952\/revisions"}],"predecessor-version":[{"id":12949,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/11952\/revisions\/12949"}],"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=11952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}