{"id":11909,"date":"2019-07-17T09:25:37","date_gmt":"2019-07-17T00:25:37","guid":{"rendered":"https:\/\/elleneast.com\/?p=11909"},"modified":"2019-08-22T19:47:20","modified_gmt":"2019-08-22T10:47:20","slug":"%e3%80%90vb-net%e3%80%91closedxml%ef%bc%9a%e3%82%b7%e3%83%bc%e3%83%88%e3%81%ae%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/elleneast.com\/?p=11909","title":{"rendered":"\u3010VB.NET\u3011ClosedXML\uff1a\u30b7\u30fc\u30c8\u306e\u64cd\u4f5c"},"content":{"rendered":"[include-page id=\u201d11760\u2033]\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u6b21<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/elleneast.com\/?p=11909\/#%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88%E3%81%AE%E3%82%B3%E3%83%94%E3%83%BC\" >\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u30b3\u30d4\u30fc<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/elleneast.com\/?p=11909\/#%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88%E3%81%AE%E8%A1%A8%E7%A4%BA%E3%83%BB%E9%9D%9E%E8%A1%A8%E7%A4%BA\" >\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u8868\u793a\u30fb\u975e\u8868\u793a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/elleneast.com\/?p=11909\/#%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88%E3%81%AE%E4%BF%9D%E8%AD%B7\" >\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u4fdd\u8b77<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/elleneast.com\/?p=11909\/#%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88%E3%81%AE%E8%A6%8B%E5%87%BA%E3%81%97%E3%81%AE%E8%89%B2\" >\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u898b\u51fa\u3057\u306e\u8272<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/elleneast.com\/?p=11909\/#%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88%E3%81%AE%E8%BF%BD%E5%8A%A0%E3%83%BB%E7%A7%BB%E5%8B%95%E3%83%BB%E5%89%8A%E9%99%A4\" >\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u8ffd\u52a0\u30fb\u79fb\u52d5\u30fb\u524a\u9664<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/elleneast.com\/?p=11909\/#%E3%82%A6%E3%82%A3%E3%83%B3%E3%83%89%E3%82%A6%E6%9E%A0%E3%81%AE%E5%9B%BA%E5%AE%9A\" >\u30a6\u30a3\u30f3\u30c9\u30a6\u67a0\u306e\u56fa\u5b9a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/elleneast.com\/?p=11909\/#%E3%82%A2%E3%82%A6%E3%83%88%E3%83%A9%E3%82%A4%E3%83%B3%E3%81%AE%E4%BD%9C%E6%88%90\" >\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u306e\u4f5c\u6210<\/a><\/li><\/ul><\/nav><\/div>\n<h2 id=\"i-0\"><span class=\"ez-toc-section\" id=\"%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88%E3%81%AE%E3%82%B3%E3%83%94%E3%83%BC\"><\/span>\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u30b3\u30d4\u30fc<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre class=\"lang:vbnet decode:true \">'\uff11\u3064\u76ee\u306e\u30ef\u30fc\u30af\u30d6\u30c3\u30af\nDim wb = New XLWorkbook\nDim ws = wb.AddWorksheet(\"Sheet1\")\n\n'Sheet1 \u306e A1 \u306b\u30c6\u30ad\u30b9\u30c8\u3092\u5165\u529b\nws.Cells(\"A1\").Value = \"(*^_^*)\"\n\n'\u30d6\u30c3\u30af\u5185\u3067\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3092\u30b3\u30d4\u30fc\u3059\u308b\nws.CopyTo(\"Sheet1 \u306e\u30b3\u30d4\u30fc\")\n\n'\uff11\u3064\u76ee\u306e\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u3092\u4fdd\u5b58\nwb.SaveAs(\"D:\\test\\wsCopyTest1.xlsx\")\n\n\n\n'\uff12\u3064\u76ee\u306e\u30ef\u30fc\u30af\u30d6\u30c3\u30af\nDim wb2 = New XLWorkbook\n'\uff11\u3064\u76ee\u306e\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u306e\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3092\n'\uff12\u3064\u76ee\u306e\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u5185\u306b\u30b3\u30d4\u30fc\u3059\u308b\nws.CopyTo(wb2, \"wsCopyTest1.xlsx \u304b\u3089\u306e\u30b3\u30d4\u30fc\")\n\n'\uff12\u3064\u76ee\u306e\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u3092\u4fdd\u5b58\nwb2.SaveAs(\"D:\\test\\wsCopyTest2.xlsx\")<\/pre>\n<h2 id=\"i-1\"><span class=\"ez-toc-section\" id=\"%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88%E3%81%AE%E8%A1%A8%E7%A4%BA%E3%83%BB%E9%9D%9E%E8%A1%A8%E7%A4%BA\"><\/span>\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u8868\u793a\u30fb\u975e\u8868\u793a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre class=\"lang:vbnet decode:true  \">Dim wb = New XLWorkbook\n\nwb.Worksheets.Add(\"Visible\")\nwb.Worksheets.Add(\"Hidden\").Hide\nwb.Worksheets.Add(\"Unhidden\").Hide.Unhide\nwb.Worksheets.Add(\"VeryHidden\").Visibility = XLWorksheetVisibility.VeryHidden\n\nwb.SaveAs(\"D;\\test\\HideWorksheets.xlsx\")<\/pre>\n<h2 id=\"i-2\"><span class=\"ez-toc-section\" id=\"%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88%E3%81%AE%E4%BF%9D%E8%AD%B7\"><\/span>\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u4fdd\u8b77<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u4e0b\u56f3\u306e\u3088\u3046\u306a\uff12\u3064\u306e\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_23c.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11933 bigshadow\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_23c.png\" alt=\"\" width=\"492\" height=\"175\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_23c.png 492w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_23c-300x107.png 300w\" sizes=\"auto, (max-width: 492px) 100vw, 492px\"><\/a><\/p>\n<ul>\n<li>A \u5217\u3067\u300c\u30ed\u30c3\u30af\u300d\u3068\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u305d\u306e\u884c\u306e B \u5217\u306e\u30c6\u30ad\u30b9\u30c8\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/li>\n<li>A \u5217\u3067\u300c\u975e\u8868\u793a\u300d\u3068\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u305d\u306e\u884c\u306e B \u5217\u306e\u30c6\u30ad\u30b9\u30c8\u3084\u6570\u5f0f\u304c\u6570\u5f0f\u30d0\u30fc\u306b\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002<\/li>\n<\/ul>\n<pre class=\"lang:vbnet decode:true \">Dim wb = new XLWorkbook\nDim ws = wb.Worksheets.Add(\"\u4fdd\u8b77\uff08\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3057\uff09\")\n\n'\u30bb\u30eb\u306e\u66f8\u5f0f\u8a2d\u5b9a\u3001\u5217\u306e\u633f\u5165\u30fb\u524a\u9664\u3001\u884c\u306e\u524a\u9664\u306e\u307f\u3092\u8a31\u53ef\nws.Protect _ \n    .SetFormatCells _\n    .SetInsertColumns _\n    .SetDeleteColumns _\n    .SetDeleteRows\n\nws.Cell(\"A1\").SetValue(\"\u30ed\u30c3\u30af\u3001\u8868\u793a\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\uff09\uff1a\").Style _\n    .Font.SetBold.Fill.SetBackgroundColor(XLColor.Cyan)\nws.Cell(\"B1\").SetValue(\"(*^\u25bd^*)\")\nws.Cell(\"B1\").Style.Border.SetOutsideBorder(XLBorderStyleValues.Medium)\n\nws.Cell(\"A2\").SetValue(\"\u30ed\u30c3\u30af\u3001\u975e\u8868\u793a\uff1a\").Style.Font.SetBold _\n    .Fill.SetBackgroundColor(XLColor.Cyan)\nws.Cell(\"B2\").Style.Protection.SetHidden.Border _\n    .SetOutsideBorder(XLBorderStyleValues.Medium)\nws.Cell(\"B2\").SetValue(\"( *\u00b4\u8278\uff40)\")\n\nws.Cell(\"A3\").SetValue(\"\u975e\u30ed\u30c3\u30af\u3001\u975e\u8868\u793a\uff1a\").Style.Font _\n    .SetBold.Fill.SetBackgroundColor(XLColor.Cyan)\nws.Cell(\"B3\").Style.Protection.SetLocked(False).Protection _\n    .SetHidden.Border.SetOutsideBorder(XLBorderStyleValues.Medium)\nws.Cell(\"B3\").SetValue(\"(*^-^*)\")\n\nws.Cell(\"A4\").SetValue(\"\u975e\u30ed\u30c3\u30af\u3001\u8868\u793a\uff1a\").Style.Font.SetBold _\n    .Fill.SetBackgroundColor(XLColor.Cyan)\nws.Cell(\"B4\").Style.Protection.SetLocked(False).Border _\n    .SetOutsideBorder(XLBorderStyleValues.Medium)\nws.Cell(\"B4\").SetValue(\"(^^\u266a\")\n\n'ws.Style.Font.FontName = \"\u6e38\u30b4\u30b7\u30c3\u30af\";\n'ws.Columns().AdjustToContents\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.Column(1).Width = 37\nws.Column(2).Width = 25\n\n'\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u4ed8\u3051\u3066\u30b7\u30fc\u30c8\u3092\u4fdd\u8b77\nDim protectedSheet = wb.Worksheets.Add(\"\u4fdd\u8b77\uff08\u30d1\u30b9\u30ef\u30fc\u30c9\u306f 123\uff09\")\nDim protection = protectedSheet.Protect(\"123\")\nprotection.InsertRows = True\nprotection.InsertColumns = True\n\nwb.SaveAs(\"D:\\test\\SheetProtection.xlsx\")<\/pre>\n<h2 id=\"i-3\"><span class=\"ez-toc-section\" id=\"%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88%E3%81%AE%E8%A6%8B%E5%87%BA%E3%81%97%E3%81%AE%E8%89%B2\"><\/span>\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u898b\u51fa\u3057\u306e\u8272<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u898b\u51fa\u3057\u306e\u8272\u3092\u4e0b\u56f3\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_24.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11936 bigshadow\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_24.png\" alt=\"\" width=\"349\" height=\"85\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_24.png 349w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_24-300x73.png 300w\" sizes=\"auto, (max-width: 349px) 100vw, 349px\"><\/a><\/p>\n<pre class=\"lang:vbnet decode:true \">Dim wb = new XLWorkbook\n\nDim wsRed = wb.Worksheets.Add(\"Red\").SetTabColor(XLColor.Red)\n\nDim wsAccent3 = wb.Worksheets.Add(\"Accent3\").SetTabColor(XLColor.FromTheme(XLThemeColor.Accent3))\n\nDim wsIndexed = wb.Worksheets.Add(\"Index\")\nwsIndexed.TabColor = XLColor.FromIndex(24)\n\nDim wsArgb = wb.Worksheets.Add(\"Argb\")\nwsArgb.TabColor = XLColor.FromArgb(23, 23, 23)\n\nwb.SaveAs(\"D:\\test\\TabColors.xlsx\")<\/pre>\n<h2 id=\"i-4\"><span class=\"ez-toc-section\" id=\"%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88%E3%81%AE%E8%BF%BD%E5%8A%A0%E3%83%BB%E7%A7%BB%E5%8B%95%E3%83%BB%E5%89%8A%E9%99%A4\"><\/span>\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u8ffd\u52a0\u30fb\u79fb\u52d5\u30fb\u524a\u9664<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre class=\"lang:vbnet decode:true \">Dim workbook = New XLWorkbook\n\n'\uff15\u679a\u306e\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3092\u8ffd\u52a0\u3059\u308b\n' --&gt; \u30b7\u30fc\u30c8\u9806\u306f Sheet 1, Sheet 2, Sheet 3, Sheet 4, Sheet 5\nFor Each wsNum As Integer in Enumerable.Range(1, 5)\n    Dim ws = workbook.Worksheets.Add(\"Sheet \" + wsNum.ToString)\nNext\n\n'\u6700\u521d\u306e\u30b7\u30fc\u30c8\u3092\u6700\u5f8c\u306b\u79fb\u52d5\n' --&gt; \u30b7\u30fc\u30c8\u9806\u306f Sheet 2, Sheet 3, Sheet 4, Sheet 5, Sheet 1\nworkbook.Worksheet(1).Position = workbook.Worksheets.Count + 1\n\n'\uff14\u756a\u76ee\u306e\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3092\u524a\u9664\n' --&gt; \u30b7\u30fc\u30c8\u9806\u306f Sheet 2, Sheet 3, Sheet 4, Sheet 1\nworkbook.Worksheet(4).Delete\n\n'\uff11\u756a\u76ee\u3068\uff12\u756a\u76ee\u306e\u30b7\u30fc\u30c8\u306e\u4f4d\u7f6e\u3092\u5165\u308c\u66ff\u3048\u308b\uff08\uff09\n' --&gt; \u30b7\u30fc\u30c8\u9806\u306f Sheet 3, Sheet 2, Sheet 4, Sheet 1\nworkbook.Worksheet(2).Position = 1\n\nworkbook.SaveAs(\"D:\\test\\MultipleSheets.xlsx\")<\/pre>\n<h2 id=\"i-5\"><span class=\"ez-toc-section\" id=\"%E3%82%A6%E3%82%A3%E3%83%B3%E3%83%89%E3%82%A6%E6%9E%A0%E3%81%AE%E5%9B%BA%E5%AE%9A\"><\/span>\u30a6\u30a3\u30f3\u30c9\u30a6\u67a0\u306e\u56fa\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre class=\"lang:vbnet decode:true \">Dim wb = new XLWorkbook\nDim wsFreeze = wb.Worksheets.Add(\"\u30a6\u30a3\u30f3\u30c9\u30a6\u67a0\u306e\u56fa\u5b9a\")\n\n'\u884c\u3068\u5217\u3092\u540c\u6642\u306b\u56fa\u5b9a\nwsFreeze.SheetView.Freeze(3, 5)\n\n'\u884c\u3068\u5217\u3092\u5225\u3005\u306b\u56fa\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\n'wsFreeze.SheetView.FreezeRows(3)\n'wsFreeze.SheetView.FreezeColumns(5)\n\n'\u56fa\u5b9a\u3092\u89e3\u9664\n'wsFreeze.SheetView.Freeze(0, 0)\n\n\n\n'SplitRow \/ SplitColumn \u3067\u3082\u3067\u304d\u307e\u3059\n'wsFreeze.SheetView.SplitRow = 3\n'wsFreeze.SheetView.SplitColumn = 5\n\n'\u56fa\u5b9a\u3092\u89e3\u9664\n'wsFreeze.SheetView.SplitRow = 0\n'wsFreeze.SheetView.SplitColumn = 0\n\nwb.SaveAs(\"D:\\test\\FreezePanes.xlsx\")<\/pre>\n<h2 id=\"i-6\"><span class=\"ez-toc-section\" id=\"%E3%82%A2%E3%82%A6%E3%83%88%E3%83%A9%E3%82%A4%E3%83%B3%E3%81%AE%E4%BD%9C%E6%88%90\"><\/span>\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u306e\u4f5c\u6210<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u4e0b\u56f3\u306e\u3088\u3046\u306a\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_16.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11904 bigshadow\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_16.png\" alt=\"\" width=\"546\" height=\"155\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_16.png 546w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ClosedXML\/ClosedXml_16-300x85.png 300w\" sizes=\"auto, (max-width: 546px) 100vw, 546px\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u30b3\u30fc\u30c9<\/p>\n<pre class=\"lang:vbnet decode:true \">Dim wb = new XLWorkbook\nDim ws = wb.Worksheets.Add(\"\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\")\n\nws.Outline.SummaryHLocation = XLOutlineSummaryHLocation.Right\nws.Columns(2, 6).Group '\u5217 2-6(B-F) \u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\uff08\u30ec\u30d9\u30eb\uff11\uff09\u3092\u4f5c\u6210\nws.Columns(2, 4).Group '\u5217 2-4(B-D) \u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\uff08\u30ec\u30d9\u30eb\uff12\uff09\u3092\u4f5c\u6210\nws.Column(2).Ungroup(True) '\u52172\u3092\u3059\u3079\u3066\u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u304b\u3089\u5916\u3059\n\nws.Outline.SummaryVLocation = XLOutlineSummaryVLocation.Bottom\nws.Rows(1, 5).Group '\u884c 1-5 \u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\uff08\u30ec\u30d9\u30eb\uff11\uff09\u3092\u4f5c\u6210\nws.Rows(1, 4).Group '\u884c 1-4 \u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\uff08\u30ec\u30d9\u30eb\uff12\uff09\u3092\u4f5c\u6210\nws.Rows(1, 4).Collapse '\u884c 1-4 \u3092\u6298\u308a\u305f\u305f\u3080\nws.Rows(1, 2).Group '\u884c 1-2 \u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\uff08\u30ec\u30d9\u30eb\uff13\uff09\u3092\u4f5c\u6210\nws.Rows(1, 2).Ungroup '\u884c 1-2 \u3092\u6700\u5f8c\u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u304b\u3089\u5916\u3059\n\n'\u7279\u5b9a\u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u30ec\u30d9\u30eb\u3092\u6298\u308a\u305f\u305f\u3093\u3060\u308a\u5c55\u958b\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\n'\n' ws.CollapseRows(outlineLevel As Int32)\n' ws.CollapseColumns(outlineLevel As Int32)\n'\n' ws.ExpandRows(outlineLevel As Int32)\n' ws.ExpandColumns(outlineLevel As Int32)\n\n'\u3059\u3079\u3066\u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u30ec\u30d9\u30eb\u3092\u4e00\u5ea6\u306b\u6298\u308a\u305f\u305f\u3093\u3060\u308a\u5c55\u958b\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\n'\n' ws.CollapseRows\n' ws.CollapseColumns\n'\n' ws.ExpandRows\n' ws.ExpandColumns\n\nwb.SaveAs(\"D:\\test\\Outline.xlsx\")<\/pre>\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] \u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u30b3\u30d4\u30fc &#8216;\uff11\u3064\u76ee\u306e\u30ef\u30fc\u30af\u30d6\u30c3\u30af Dim wb = New XLWorkbook Dim ws = wb.AddWorksheet(&#8220;Sheet1&#8221;) &#8216;S &#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-11909","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\/11909","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=11909"}],"version-history":[{"count":3,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/11909\/revisions"}],"predecessor-version":[{"id":12954,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/11909\/revisions\/12954"}],"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=11909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}