{"id":118,"date":"2026-06-28T06:19:05","date_gmt":"2026-06-27T21:19:05","guid":{"rendered":"https:\/\/www.tech-undefined.com\/?p=118"},"modified":"2026-06-28T12:31:43","modified_gmt":"2026-06-28T03:31:43","slug":"datatables-csv-download","status":"publish","type":"post","link":"https:\/\/www.tech-undefined.com\/?p=118","title":{"rendered":"\u3010DataTables\u3011\u30c7\u30fc\u30bf\u3092CSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>DataTables\u306e\u4e00\u89a7\u306bCSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3092\u4ed8\u3051\u308b\u3060\u3051\u306a\u3089\u3001Buttons\u62e1\u5f35\u3092\u4f7f\u3046\u306e\u304c\u4e00\u756a\u65e9\u3044\u3067\u3059\u3002<br \/>\u305f\u3060\u3057\u3001<code>serverSide: true<\/code>\u3067\u30b5\u30fc\u30d0\u30fc\u5074\u51e6\u7406\u306b\u3057\u3066\u3044\u308b\u753b\u9762\u3067\u306f\u3001\u300c\u753b\u9762\u306b\u898b\u3048\u3066\u3044\u308b\u5206\u300d\u3068\u300cCSV\u306b\u51fa\u3057\u305f\u3044\u5168\u91cf\u300d\u304c\u305a\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001Buttons\u62e1\u5f35\u3067CSV\u30dc\u30bf\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u57fa\u672c\u5f62\u3068\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u51e6\u7406\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u306b\u5168\u91cfCSV\u3092\u51fa\u3059\u8a2d\u8a08\u3092\u6574\u7406\u3057\u307e\u3059\u3002<br \/>\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u4e00\u5ea6\u306b\u5168\u4ef6CSV\u3092\u4f5c\u308b\u3068\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u304c\u5927\u304d\u304f\u306a\u308b\u3053\u3068\u3082\u3042\u308b\u305f\u3081\u3001\u65e2\u5b58\u306e\u30da\u30fc\u30b8\u30f3\u30b0API\u3092\u7e70\u308a\u8fd4\u3057\u547c\u3073\u51fa\u3057\u3066\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3067CSV\u3092\u7d44\u307f\u7acb\u3066\u308b\u65b9\u6cd5\u3082\u3042\u308f\u305b\u3066\u6271\u3044\u307e\u3059\u3002<\/p>\n<h2>\u516c\u5f0f\u30da\u30fc\u30b8<\/h2>\n<ul>\n<li><a href=\"https:\/\/datatables.net\/extensions\/buttons\/\">DataTables Buttons<\/a><\/li>\n<li><a href=\"https:\/\/datatables.net\/reference\/button\/csvHtml5\">csvHtml5<\/a><\/li>\n<li><a href=\"https:\/\/datatables.net\/reference\/api\/buttons.exportData%28%29\">buttons.exportData()<\/a><\/li>\n<li><a href=\"https:\/\/datatables.net\/manual\/server-side\">Server-side processing<\/a><\/li>\n<\/ul>\n<h2>Buttons\u62e1\u5f35\u3092\u4f7f\u3046<\/h2>\n<p>DataTables\u672c\u4f53\u3060\u3051\u3067\u306fCSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30dc\u30bf\u30f3\u306f\u4f7f\u3048\u307e\u305b\u3093\u3002<br \/>CSV\u3001Excel\u3001PDF\u3001\u30b3\u30d4\u30fc\u306a\u3069\u306e\u51fa\u529b\u6a5f\u80fd\u3092\u4f7f\u3046\u306b\u306f\u3001Buttons\u62e1\u5f35\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n<p>CDN\u3067\u8aad\u307f\u8fbc\u3080\u5834\u5408\u306e\u4f8b\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-html\">&lt;link rel=&quot;stylesheet&quot; href=&quot;https:\/\/cdn.datatables.net\/2.3.8\/css\/dataTables.dataTables.min.css&quot;&gt;\n&lt;link rel=&quot;stylesheet&quot; href=&quot;https:\/\/cdn.datatables.net\/buttons\/3.2.5\/css\/buttons.dataTables.min.css&quot;&gt;\n\n&lt;scr&#105;pt src=&quot;https:\/\/code.jquery.com\/jquery-3.7.1.min.js&quot;&gt;&lt;\/scr&#105;pt&gt;\n&lt;scr&#105;pt src=&quot;https:\/\/cdn.datatables.net\/2.3.8\/js\/dataTables.min.js&quot;&gt;&lt;\/scr&#105;pt&gt;\n&lt;scr&#105;pt src=&quot;https:\/\/cdn.datatables.net\/buttons\/3.2.5\/js\/dataTables.buttons.min.js&quot;&gt;&lt;\/scr&#105;pt&gt;\n&lt;scr&#105;pt src=&quot;https:\/\/cdn.datatables.net\/buttons\/3.2.5\/js\/buttons.html5.min.js&quot;&gt;&lt;\/scr&#105;pt&gt;<\/code><\/pre>\n<p>Buttons\u3092\u4f7f\u3046\u5834\u5408\u306f\u3001DataTables\u672c\u4f53\u306b\u52a0\u3048\u3066\u4ee5\u4e0b\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<ul>\n<li>Buttons\u672c\u4f53<\/li>\n<li>HTML5\u51fa\u529b\u7528\u306eButtons\u30d7\u30e9\u30b0\u30a4\u30f3<\/li>\n<li>Buttons\u7528\u306eCSS<\/li>\n<\/ul>\n<p>\u5b9f\u969b\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3084\u7d44\u307f\u5408\u308f\u305b\u306f\u3001DataTables\u306eDownload Builder\u3067\u9078\u3076\u3068\u9593\u9055\u3044\u306b\u304f\u3044\u3067\u3059\u3002<\/p>\n<h2>CSV\u30dc\u30bf\u30f3\u3092\u8ffd\u52a0\u3059\u308b<\/h2>\n<p>DataTables 2\u7cfb\u3067\u306f\u3001<code>layout<\/code>\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u30dc\u30bf\u30f3\u306e\u8868\u793a\u4f4d\u7f6e\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">new DataTable(&#x27;#usersTable&#x27;, {\n    layout: {\n        topStart: {\n            buttons: [&#x27;csvHtml5&#x27;]\n        }\n    }\n});<\/code><\/pre>\n<p>\u3053\u308c\u3060\u3051\u3067\u3001DataTables\u306e\u4e0a\u90e8\u306bCSV\u51fa\u529b\u30dc\u30bf\u30f3\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><code>csvHtml5<\/code>\u306e\u4ee3\u308f\u308a\u306b\u3001\u77ed\u3044\u5225\u540d\u3068\u3057\u3066<code>csv<\/code>\u3082\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">new DataTable(&#x27;#usersTable&#x27;, {\n    layout: {\n        topStart: {\n            buttons: [&#x27;csv&#x27;]\n        }\n    }\n});<\/code><\/pre>\n<p>DataTables 1.x\u7cfb\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u3001<code>dom: &#x27;Bfrtip&#x27;<\/code>\u306e\u3088\u3046\u306a\u66f8\u304d\u65b9\u3082\u3088\u304f\u898b\u304b\u3051\u307e\u3059\u3002<br \/>DataTables 2\u7cfb\u3067\u3082\u4e92\u63db\u306e\u305f\u3081\u306b\u4f7f\u3048\u307e\u3059\u304c\u3001\u65b0\u3057\u304f\u66f8\u304f\u306a\u3089<code>layout<\/code>\u3092\u4f7f\u3046\u65b9\u304c\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<h2>\u30dc\u30bf\u30f3\u540d\u3084\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u5909\u66f4\u3059\u308b<\/h2>\n<p>\u30dc\u30bf\u30f3\u306e\u8868\u793a\u540d\u3084\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u5909\u3048\u305f\u3044\u5834\u5408\u306f\u3001\u30dc\u30bf\u30f3\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">new DataTable(&#x27;#usersTable&#x27;, {\n    layout: {\n        topStart: {\n            buttons: [\n                {\n                    extend: &#x27;csvHtml5&#x27;,\n                    text: &#x27;CSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9&#x27;,\n                    filename: &#x27;users&#x27;,\n                    bom: true\n                }\n            ]\n        }\n    }\n});<\/code><\/pre>\n<p><code>text<\/code>\u306f\u30dc\u30bf\u30f3\u306b\u8868\u793a\u3059\u308b\u6587\u5b57\u3001<code>filename<\/code>\u306f\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u3059\u3002<br \/><code>bom: true<\/code>\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001UTF-8 BOM\u4ed8\u304d\u306eCSV\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>Excel\u3067\u65e5\u672c\u8a9eCSV\u3092\u958b\u304f\u5834\u5408\u3001\u74b0\u5883\u306b\u3088\u3063\u3066\u306fBOM\u304c\u306a\u3044\u3068\u6587\u5b57\u5316\u3051\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\u305d\u306e\u305f\u3081\u3001\u65e5\u672c\u8a9e\u306eCSV\u3092Excel\u3067\u958b\u304f\u60f3\u5b9a\u304c\u3042\u308b\u5834\u5408\u306f\u3001<code>bom: true<\/code>\u3092\u4ed8\u3051\u3066\u304a\u304f\u3068\u6271\u3044\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<h2>\u51fa\u529b\u3059\u308b\u5217\u3092\u6307\u5b9a\u3059\u308b<\/h2>\n<p>\u64cd\u4f5c\u30dc\u30bf\u30f3\u5217\u3084\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u5217\u306a\u3069\u3001CSV\u306b\u51fa\u3057\u305f\u304f\u306a\u3044\u5217\u304c\u3042\u308b\u5834\u5408\u306f<code>exportOptions.columns<\/code>\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">new DataTable(&#x27;#usersTable&#x27;, {\n    layout: {\n        topStart: {\n            buttons: [\n                {\n                    extend: &#x27;csvHtml5&#x27;,\n                    text: &#x27;CSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9&#x27;,\n                    bom: true,\n                    exportOptions: {\n                        columns: [0, 1, 2]\n                    }\n                }\n            ]\n        }\n    }\n});<\/code><\/pre>\n<p>\u8868\u793a\u4e2d\u306e\u5217\u3060\u3051\u3092\u51fa\u529b\u3057\u305f\u3044\u5834\u5408\u306f\u3001<code>:visible<\/code>\u3082\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">new DataTable(&#x27;#usersTable&#x27;, {\n    layout: {\n        topStart: {\n            buttons: [\n                {\n                    extend: &#x27;csvHtml5&#x27;,\n                    text: &#x27;\u8868\u793a\u5217\u3092CSV\u51fa\u529b&#x27;,\n                    exportOptions: {\n                        columns: &#x27;:visible&#x27;\n                    }\n                }\n            ]\n        }\n    }\n});<\/code><\/pre>\n<p>\u753b\u9762\u306b\u64cd\u4f5c\u5217\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u64cd\u4f5c\u5217\u3092CSV\u5bfe\u8c61\u5916\u306b\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">new DataTable(&#x27;#usersTable&#x27;, {\n    columns: [\n        { data: &#x27;id&#x27;, title: &#x27;ID&#x27; },\n        { data: &#x27;name&#x27;, title: &#x27;\u540d\u524d&#x27; },\n        { data: &#x27;email&#x27;, title: &#x27;\u30e1\u30fc\u30eb&#x27; },\n        {\n            data: null,\n            title: &#x27;\u64cd\u4f5c&#x27;,\n            searchable: false,\n            orderable: false,\n            render: function () {\n                return &#x27;&lt;button type=&quot;button&quot;&gt;\u8a73\u7d30&lt;\/button&gt;&#x27;;\n            }\n        }\n    ],\n    layout: {\n        topStart: {\n            buttons: [\n                {\n                    extend: &#x27;csvHtml5&#x27;,\n                    text: &#x27;CSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9&#x27;,\n                    exportOptions: {\n                        columns: [0, 1, 2]\n                    }\n                }\n            ]\n        }\n    }\n});<\/code><\/pre>\n<h2>\u691c\u7d22\u7d50\u679c\u3060\u3051\u51fa\u529b\u3059\u308b<\/h2>\n<p>DataTables\u306eCSV\u51fa\u529b\u306f\u3001\u691c\u7d22\u3084\u4e26\u3073\u66ff\u3048\u306e\u72b6\u614b\u3092\u53cd\u6620\u3067\u304d\u307e\u3059\u3002<br \/>\u6a19\u6e96\u3067\u306f\u3001\u691c\u7d22\u6761\u4ef6\u3084\u4e26\u3073\u66ff\u3048\u304c\u53cd\u6620\u3055\u308c\u305f\u30c7\u30fc\u30bf\u304c\u51fa\u529b\u5bfe\u8c61\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u691c\u7d22\u6761\u4ef6\u3092\u7121\u8996\u3057\u3066\u3001DataTables\u304c\u6301\u3063\u3066\u3044\u308b\u5168\u30c7\u30fc\u30bf\u3092\u51fa\u529b\u3057\u305f\u3044\u5834\u5408\u306f\u3001<code>exportOptions.modifier.search<\/code>\u3092<code>none<\/code>\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">new DataTable(&#x27;#usersTable&#x27;, {\n    layout: {\n        topStart: {\n            buttons: [\n                {\n                    extend: &#x27;csvHtml5&#x27;,\n                    text: &#x27;\u5168\u30c7\u30fc\u30bf\u3092CSV\u51fa\u529b&#x27;,\n                    exportOptions: {\n                        modifier: {\n                            search: &#x27;none&#x27;\n                        }\n                    }\n                }\n            ]\n        }\n    }\n});<\/code><\/pre>\n<p>\u3053\u306e\u65b9\u6cd5\u306f\u3001DataTables\u304c\u30d6\u30e9\u30a6\u30b6\u5074\u306b\u5168\u30c7\u30fc\u30bf\u3092\u6301\u3063\u3066\u3044\u308b\u5834\u5408\u306b\u6709\u52b9\u3067\u3059\u3002<br \/>\u305f\u3068\u3048\u3070\u3001HTML\u306e<code>tbody<\/code>\u306b\u5168\u4ef6\u304c\u3042\u308b\u5834\u5408\u3084\u3001Ajax\u3067\u5168\u4ef6\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3044\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<h2>serverSide\u3067\u306f\u73fe\u5728\u30da\u30fc\u30b8\u5206\u3057\u304b\u51fa\u306a\u3044\u3053\u3068\u304c\u3042\u308b<\/h2>\n<p><code>serverSide: true<\/code>\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u3001DataTables\u306f\u30da\u30fc\u30b8\u30f3\u30b0\u3001\u691c\u7d22\u3001\u4e26\u3073\u66ff\u3048\u306e\u305f\u3073\u306b\u30b5\u30fc\u30d0\u30fc\u3078Ajax\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u308a\u307e\u3059\u3002<br \/>\u30d6\u30e9\u30a6\u30b6\u5074\u306b\u306f\u3001\u57fa\u672c\u7684\u306b\u73fe\u5728\u8868\u793a\u306b\u5fc5\u8981\u306a\u5206\u306e\u30c7\u30fc\u30bf\u3060\u3051\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001Buttons\u306eCSV\u51fa\u529b\u3092\u305d\u306e\u307e\u307e\u4f7f\u3046\u3068\u3001\u73fe\u5728\u306e\u30da\u30fc\u30b8\u306b\u3042\u308b\u30c7\u30fc\u30bf\u3060\u3051\u304cCSV\u51fa\u529b\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">new DataTable(&#x27;#usersTable&#x27;, {\n    processing: true,\n    serverSide: true,\n    ajax: &#x27;\/api\/users&#x27;,\n    layout: {\n        topStart: {\n            buttons: [&#x27;csvHtml5&#x27;]\n        }\n    },\n    columns: [\n        { data: &#x27;id&#x27;, title: &#x27;ID&#x27; },\n        { data: &#x27;name&#x27;, title: &#x27;\u540d\u524d&#x27; },\n        { data: &#x27;email&#x27;, title: &#x27;\u30e1\u30fc\u30eb&#x27; }\n    ]\n});<\/code><\/pre>\n<p>\u3053\u306e\u72b6\u614b\u3067CSV\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u3082\u3001DataTables\u304c\u30d6\u30e9\u30a6\u30b6\u5074\u306b\u6301\u3063\u3066\u3044\u306a\u3044\u884c\u306f\u51fa\u529b\u3067\u304d\u307e\u305b\u3093\u3002<br \/><code>exportOptions.modifier.search: &#x27;none&#x27;<\/code>\u3092\u4ed8\u3051\u3066\u3082\u3001\u30b5\u30fc\u30d0\u30fc\u4e0a\u306b\u3057\u304b\u306a\u3044\u5168\u4ef6\u30c7\u30fc\u30bf\u3092\u30d6\u30e9\u30a6\u30b6\u3060\u3051\u3067\u51fa\u529b\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<h2>serverSide\u3067\u5168\u91cfCSV\u3092\u51fa\u3057\u305f\u3044\u5834\u5408<\/h2>\n<p>\u30b5\u30fc\u30d0\u30fc\u5074\u51e6\u7406\u3092\u4f7f\u3063\u3066\u3044\u308b\u753b\u9762\u3067\u5168\u91cfCSV\u3092\u51fa\u3057\u305f\u3044\u5834\u5408\u306f\u3001CSV\u51fa\u529b\u7528\u306e\u5c02\u7528\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u4f5c\u308b\u306e\u304c\u5b89\u5168\u3067\u3059\u3002<\/p>\n<p>\u8003\u3048\u65b9\u306f\u4ee5\u4e0b\u3067\u3059\u3002<\/p>\n<ol>\n<li>DataTables\u306e\u753b\u9762\u8868\u793a\u306f<code>serverSide: true<\/code>\u3067\u30da\u30fc\u30b8\u5358\u4f4d\u306b\u53d6\u5f97\u3059\u308b<\/li>\n<li>CSV\u30dc\u30bf\u30f3\u306fDataTables\u306e\u6a19\u6e96CSV\u51fa\u529b\u3067\u306f\u306a\u304f\u3001\u72ec\u81ea\u30dc\u30bf\u30f3\u306b\u3059\u308b<\/li>\n<li>\u73fe\u5728\u306e\u691c\u7d22\u6761\u4ef6\u3084\u4e26\u3073\u66ff\u3048\u6761\u4ef6\u3092CSV\u7528API\u3078\u6e21\u3059<\/li>\n<li>\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u6761\u4ef6\u306b\u5408\u3046\u5168\u4ef6\u3092CSV\u3068\u3057\u3066\u8fd4\u3059<\/li>\n<li>\u30d6\u30e9\u30a6\u30b6\u306fCSV\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/li>\n<\/ol>\n<p>\u30d5\u30ed\u30f3\u30c8\u5074\u306e\u4f8b\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">const table = new DataTable(&#x27;#usersTable&#x27;, {\n    processing: true,\n    serverSide: true,\n    ajax: {\n        url: &#x27;\/api\/users\/search&#x27;,\n        type: &#x27;POST&#x27;\n    },\n    columns: [\n        { data: &#x27;id&#x27;, title: &#x27;ID&#x27;, name: &#x27;id&#x27; },\n        { data: &#x27;name&#x27;, title: &#x27;\u540d\u524d&#x27;, name: &#x27;name&#x27; },\n        { data: &#x27;email&#x27;, title: &#x27;\u30e1\u30fc\u30eb&#x27;, name: &#x27;email&#x27; },\n        { data: &#x27;createdAt&#x27;, title: &#x27;\u767b\u9332\u65e5&#x27;, name: &#x27;created_at&#x27; }\n    ],\n    layout: {\n        topStart: {\n            buttons: [\n                {\n                    text: &#x27;\u5168\u4ef6CSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9&#x27;,\n                    action: function () {\n                        downloadAllUsersCsv(table);\n                    }\n                }\n            ]\n        }\n    }\n});<\/code><\/pre>\n<p>CSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u95a2\u6570\u306e\u4f8b\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">function downloadAllUsersCsv(table) {\n    const params = table.ajax.params();\n    const query = new URLSearchParams();\n\n    query.set(&#x27;search&#x27;, params.search.value ?? &#x27;&#x27;);\n\n    if (params.order.length &gt; 0) {\n        const order = params.order[0];\n        const column = params.columns[order.column];\n\n        query.set(&#x27;orderColumn&#x27;, column.name);\n        query.set(&#x27;orderDir&#x27;, order.dir);\n    }\n\n    window.location.href = `\/api\/users\/csv?${query.toString()}`;\n}<\/code><\/pre>\n<p><code>table.ajax.params()<\/code>\u3092\u4f7f\u3046\u3068\u3001DataTables\u304c\u76f4\u8fd1\u306eAjax\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u9001\u3063\u305f\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<br \/>\u305d\u3053\u304b\u3089\u691c\u7d22\u6761\u4ef6\u3084\u4e26\u3073\u66ff\u3048\u6761\u4ef6\u3092\u53d6\u308a\u51fa\u3057\u3001CSV\u7528API\u3078\u6e21\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u4f8b\u3067\u306f<code>GET<\/code>\u3067CSV\u3092\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\u691c\u7d22\u6761\u4ef6\u304c\u591a\u3044\u5834\u5408\u3084\u3001\u6761\u4ef6\u304c\u9577\u304f\u306a\u308b\u5834\u5408\u306f<code>POST<\/code>\u3067CSV\u4f5c\u6210\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u308b\u8a2d\u8a08\u306b\u3057\u3066\u3082\u3088\u3044\u3067\u3059\u3002<\/p>\n<h2>\u30b5\u30fc\u30d0\u30fc\u5074CSV API\u306e\u8003\u3048\u65b9<\/h2>\n<p>CSV\u7528API\u3067\u306f\u3001DataTables\u306e\u30da\u30fc\u30b8\u30f3\u30b0\u7528API\u3068\u306f\u9055\u3044\u3001\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u5168\u4ef6\u3092\u5bfe\u8c61\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>Node.js\u306e\u7591\u4f3c\u30b3\u30fc\u30c9\u3067\u66f8\u304f\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">app.get(&#x27;\/api\/users\/csv&#x27;, async (req, res) =&gt; {\n    const search = String(req.query.search ?? &#x27;&#x27;);\n    const orderColumn = getAllowedOrderColumn(req.query.orderColumn);\n    const orderDir = req.query.orderDir === &#x27;desc&#x27; ? &#x27;DESC&#x27; : &#x27;ASC&#x27;;\n\n    const rows = await userRepository.findAllForCsv({\n        search,\n        orderColumn,\n        orderDir\n    });\n\n    res.setHeader(&#x27;Content-Type&#x27;, &#x27;text\/csv; charset=utf-8&#x27;);\n    res.setHeader(&#x27;Content-Disposition&#x27;, &#x27;attachment; filename=&quot;users.csv&quot;&#x27;);\n\n    res.write(&#x27;\\uFEFF&#x27;);\n    res.write(&#x27;ID,\u540d\u524d,\u30e1\u30fc\u30eb,\u767b\u9332\u65e5\\n&#x27;);\n\n    for (const row of rows) {\n        res.write([\n            csvEscape(row.id),\n            csvEscape(row.name),\n            csvEscape(row.email),\n            csvEscape(row.createdAt)\n        ].join(&#x27;,&#x27;) + &#x27;\\n&#x27;);\n    }\n\n    res.end();\n});<\/code><\/pre>\n<p>CSV\u306e1\u9805\u76ee\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u3059\u308b\u95a2\u6570\u306e\u4f8b\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">function csvEscape(value) {\n    const text = String(value ?? &#x27;&#x27;);\n    const escaped = text.replaceAll(&#x27;&quot;&#x27;, &#x27;&quot;&quot;&#x27;);\n    return `&quot;${escaped}&quot;`;\n}<\/code><\/pre>\n<p>CSV\u3067\u306f\u3001\u30ab\u30f3\u30de\u3001\u6539\u884c\u3001\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c8\u3092\u542b\u3080\u5024\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<br \/>\u57fa\u672c\u7684\u306b\u306f\u5404\u5024\u3092\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c8\u3067\u56f2\u307f\u3001\u5024\u306e\u4e2d\u306e\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c8\u306f<code>&quot;&quot;<\/code>\u306b\u3057\u307e\u3059\u3002<\/p>\n<h2>\u65e2\u5b58\u306e\u30da\u30fc\u30b8\u30f3\u30b0API\u3092\u4f7f\u3063\u3066\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3067\u5168\u4ef6CSV\u3092\u4f5c\u308b<\/h2>\n<p>CSV\u5c02\u7528API\u3067\u30b5\u30fc\u30d0\u30fc\u5074\u304c\u5168\u4ef6\u3092\u53d6\u5f97\u3057\u3066CSV\u3092\u4f5c\u308b\u65b9\u6cd5\u306f\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u304c\u3001\u5bfe\u8c61\u4ef6\u6570\u304c\u591a\u3044\u5834\u5408\u306f\u30b5\u30fc\u30d0\u30fc\u5074\u306e\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u304c\u5927\u304d\u304f\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\u7279\u306b\u3001\u5168\u4ef6\u3092\u914d\u5217\u306b\u8aad\u307f\u8fbc\u3093\u3067\u304b\u3089CSV\u6587\u5b57\u5217\u3092\u4f5c\u308b\u5b9f\u88c5\u306b\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u4ef6\u6570\u3084\u5217\u6570\u306b\u3088\u3063\u3066\u306f\u30e1\u30e2\u30ea\u3092\u5727\u8feb\u3057\u307e\u3059\u3002<\/p>\n<p>\u3059\u3067\u306bDataTables\u7528\u306e\u30da\u30fc\u30b8\u30f3\u30b0API\u304c\u3042\u308b\u306a\u3089\u3001\u305d\u306eAPI\u3092\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u304b\u3089\u30da\u30fc\u30b8\u3054\u3068\u306b\u547c\u3073\u51fa\u3057\u3001\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092\u5c11\u3057\u305a\u3064CSV\u884c\u3078\u5909\u63db\u3059\u308b\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u3002<br \/>\u3053\u306e\u65b9\u6cd5\u3067\u306f\u30b5\u30fc\u30d0\u30fc\u306f\u901a\u5e38\u306e\u30da\u30fc\u30b8\u53d6\u5f97\u51e6\u7406\u3092\u7e70\u308a\u8fd4\u3059\u3060\u3051\u306a\u306e\u3067\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u5de8\u5927\u306aCSV\u3092\u4e00\u5ea6\u306b\u7d44\u307f\u7acb\u3066\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u8003\u3048\u65b9\u306f\u4ee5\u4e0b\u3067\u3059\u3002<\/p>\n<ol>\n<li>\u73fe\u5728\u306e\u691c\u7d22\u6761\u4ef6\u3084\u4e26\u3073\u66ff\u3048\u6761\u4ef6\u3092<code>table.ajax.params()<\/code>\u304b\u3089\u53d6\u5f97\u3059\u308b<\/li>\n<li><code>start<\/code>\u3068<code>length<\/code>\u3092\u6307\u5b9a\u3057\u3066\u3001\u65e2\u5b58\u306eDataTables\u7528API\u3092\u30da\u30fc\u30b8\u3054\u3068\u306b\u547c\u3073\u51fa\u3059<\/li>\n<li>\u30ec\u30b9\u30dd\u30f3\u30b9\u306e<code>data<\/code>\u3092CSV\u884c\u306b\u5909\u63db\u3057\u3066\u914d\u5217\u3078\u8ffd\u52a0\u3059\u308b<\/li>\n<li><code>recordsFiltered<\/code>\u306b\u9054\u3059\u308b\u307e\u3067\u7e70\u308a\u8fd4\u3059<\/li>\n<li>\u6700\u5f8c\u306bBlob\u3092\u4f5c\u3063\u3066CSV\u3068\u3057\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/li>\n<\/ol>\n<p>\u4f8b\u3068\u3057\u3066\u3001\u65e2\u5b58\u306e<code>\/api\/users\/search<\/code>\u304cDataTables\u306e\u30b5\u30fc\u30d0\u30fc\u5074\u51e6\u7406\u5f62\u5f0f\u3067\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059\u5834\u5408\u3092\u8003\u3048\u307e\u3059\u3002<br \/><code>recordsFiltered<\/code>\u306b\u306f\u691c\u7d22\u5f8c\u306e\u7dcf\u4ef6\u6570\u3001<code>data<\/code>\u306b\u306f\u305d\u306e\u30da\u30fc\u30b8\u5206\u306e\u30c7\u30fc\u30bf\u304c\u5165\u3063\u3066\u3044\u308b\u60f3\u5b9a\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">async function downloadAllUsersCsvByPages(table) {\n    const baseParams = table.ajax.params();\n    const pageSize = 1000;\n    const rows = [[&#x27;ID&#x27;, &#x27;\u540d\u524d&#x27;, &#x27;\u30e1\u30fc\u30eb&#x27;, &#x27;\u767b\u9332\u65e5&#x27;]];\n\n    let start = 0;\n    let total = null;\n\n    while (total === null || start &lt; total) {\n        const params = {\n            ...baseParams,\n            start,\n            length: pageSize\n        };\n\n        const response = await fetch(&#x27;\/api\/users\/search&#x27;, {\n            method: &#x27;POST&#x27;,\n            headers: {\n                &#x27;Content-Type&#x27;: &#x27;application\/json&#x27;,\n                &#x27;X-CSRF-Token&#x27;: csrfToken\n            },\n            body: JSON.stringify(params)\n        });\n\n        if (!response.ok) {\n            alert(&#x27;CSV\u7528\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002&#x27;);\n            return;\n        }\n\n        const result = await response.json();\n        total = result.recordsFiltered;\n\n        for (const user of result.data) {\n            rows.push([\n                user.id,\n                user.name,\n                user.email,\n                user.createdAt\n            ]);\n        }\n\n        start += pageSize;\n    }\n\n    downloadCsvRows(rows, &#x27;users.csv&#x27;);\n}<\/code><\/pre>\n<p>CSV\u3068\u3057\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u51e6\u7406\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5206\u3051\u3066\u304a\u304f\u3068\u3001\u4ed6\u306e\u4e00\u89a7\u3067\u3082\u4f7f\u3044\u56de\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">function downloadCsvRows(rows, filename) {\n    const csv = rows\n        .map(row =&gt; row.map(csvEscape).join(&#x27;,&#x27;))\n        .join(&#x27;\\n&#x27;);\n\n    const blob = new Blob([&#x27;\\uFEFF&#x27;, csv], {\n        type: &#x27;text\/csv;charset=utf-8&#x27;\n    });\n\n    const url = URL.createObjectURL(blob);\n    const link = document.createElement(&#x27;a&#x27;);\n\n    link.href = url;\n    link.download = filename;\n    link.click();\n\n    URL.revokeObjectURL(url);\n}<\/code><\/pre>\n<p>\u3053\u306e\u65b9\u5f0f\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u306e\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u6291\u3048\u3084\u3059\u3044\u4e00\u65b9\u3067\u3001\u30d6\u30e9\u30a6\u30b6\u5074\u306b\u306f\u6700\u7d42\u7684\u306aCSV\u30c7\u30fc\u30bf\u304c\u96c6\u307e\u308a\u307e\u3059\u3002<br \/>\u305d\u306e\u305f\u3081\u3001\u6570\u5341\u4e07\u4ef6\u306e\u3088\u3046\u306a\u5927\u304d\u306a\u30c7\u30fc\u30bf\u3067\u306f\u3001\u4eca\u5ea6\u306f\u30d6\u30e9\u30a6\u30b6\u5074\u306e\u30e1\u30e2\u30ea\u3084\u51e6\u7406\u6642\u9593\u304c\u554f\u984c\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\u3042\u304f\u307e\u3067\u300c\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u5de8\u5927CSV\u3092\u4e00\u62ec\u751f\u6210\u3057\u305f\u304f\u306a\u3044\u304c\u3001\u65e2\u5b58\u306e\u30da\u30fc\u30b8\u30f3\u30b0API\u3067\u73fe\u5b9f\u7684\u306b\u53d6\u5f97\u3067\u304d\u308b\u4ef6\u6570\u300d\u306e\u305f\u3081\u306e\u9078\u629e\u80a2\u3068\u3057\u3066\u8003\u3048\u308b\u306e\u304c\u3088\u3044\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u904b\u7528\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5236\u5fa1\u3082\u5165\u308c\u3066\u304a\u304f\u3068\u5b89\u5168\u3067\u3059\u3002<\/p>\n<ul>\n<li>CSV\u51fa\u529b\u3067\u304d\u308b\u6700\u5927\u4ef6\u6570\u3092\u6c7a\u3081\u308b<\/li>\n<li>\u53d6\u5f97\u4e2d\u306f\u30dc\u30bf\u30f3\u3092\u7121\u52b9\u5316\u3057\u3066\u4e8c\u91cd\u5b9f\u884c\u3092\u9632\u3050<\/li>\n<li>\u9032\u6357\u8868\u793a\u3092\u51fa\u3059<\/li>\n<li>1\u56de\u306e<code>length<\/code>\u3092\u5927\u304d\u304f\u3057\u3059\u304e\u306a\u3044<\/li>\n<li>API\u5074\u3067\u3082<code>length<\/code>\u306e\u4e0a\u9650\u3092\u56fa\u5b9a\u3059\u308b<\/li>\n<li>\u6a29\u9650\u30c1\u30a7\u30c3\u30af\u306f\u5404\u30da\u30fc\u30b8\u53d6\u5f97API\u3067\u3082\u5fc5\u305a\u884c\u3046<\/li>\n<\/ul>\n<p>\u4ef6\u6570\u304c\u975e\u5e38\u306b\u591a\u3044\u5834\u5408\u3084\u3001CSV\u4f5c\u6210\u306b\u6642\u9593\u304c\u304b\u304b\u308b\u5834\u5408\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u30b9\u30c8\u30ea\u30fc\u30df\u30f3\u30b0\u51fa\u529b\u3059\u308b\u3001\u307e\u305f\u306f\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u30b8\u30e7\u30d6\u3067CSV\u3092\u4f5c\u6210\u3057\u3066\u5f8c\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\u65b9\u5f0f\u3082\u691c\u8a0e\u3057\u307e\u3059\u3002<br \/>\u3069\u306e\u65b9\u5f0f\u3067\u3082\u3001\u753b\u9762\u8868\u793a\u7528\u306e\u30da\u30fc\u30b8\u30f3\u30b0API\u3068CSV\u51fa\u529b\u306e\u8981\u4ef6\u3092\u5206\u3051\u3066\u8003\u3048\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n<h2>\u4e26\u3073\u66ff\u3048\u30ab\u30e9\u30e0\u306f\u30db\u30ef\u30a4\u30c8\u30ea\u30b9\u30c8\u3067\u5236\u9650\u3059\u308b<\/h2>\n<p>CSV\u7528API\u3067\u306f\u3001\u753b\u9762\u304b\u3089\u9001\u3089\u308c\u3066\u304d\u305f<code>orderColumn<\/code>\u3092\u305d\u306e\u307e\u307eSQL\u306b\u5165\u308c\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">const ORDER_COLUMNS = {\n    id: &#x27;id&#x27;,\n    name: &#x27;name&#x27;,\n    email: &#x27;email&#x27;,\n    created_at: &#x27;created_at&#x27;\n};\n\nfunction getAllowedOrderColumn(value) {\n    return ORDER_COLUMNS[value] ?? &#x27;id&#x27;;\n}<\/code><\/pre>\n<p>DataTables\u306e<code>columns.name<\/code>\u306b\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u8a31\u53ef\u3057\u305f\u540d\u524d\u3092\u5165\u308c\u3066\u304a\u304f\u3068\u6271\u3044\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">columns: [\n    { data: &#x27;id&#x27;, title: &#x27;ID&#x27;, name: &#x27;id&#x27; },\n    { data: &#x27;name&#x27;, title: &#x27;\u540d\u524d&#x27;, name: &#x27;name&#x27; },\n    { data: &#x27;email&#x27;, title: &#x27;\u30e1\u30fc\u30eb&#x27;, name: &#x27;email&#x27; },\n    { data: &#x27;createdAt&#x27;, title: &#x27;\u767b\u9332\u65e5&#x27;, name: &#x27;created_at&#x27; }\n]<\/code><\/pre>\n<p>\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u306f\u3001\u53d7\u3051\u53d6\u3063\u305f\u5024\u3092\u30db\u30ef\u30a4\u30c8\u30ea\u30b9\u30c8\u306b\u901a\u3057\u3066\u304b\u3089\u4f7f\u3044\u307e\u3059\u3002<br \/>SQL\u3092\u7d44\u307f\u7acb\u3066\u308b\u5834\u5408\u306f\u3001\u5024\u306e\u57cb\u3081\u8fbc\u307f\u306b\u3082\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u3084\u30af\u30a8\u30ea\u30d3\u30eb\u30c0\u3092\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>POST\u3067CSV\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408<\/h2>\n<p>\u691c\u7d22\u6761\u4ef6\u304c\u8907\u96d1\u306a\u5834\u5408\u306f\u3001<code>window.location.href<\/code>\u3067\u306f\u306a\u304f<code>fetch<\/code>\u3067POST\u3057\u3001Blob\u3068\u3057\u3066CSV\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">async function downloadAllUsersCsv(table) {\n    const params = table.ajax.params();\n\n    const response = await fetch(&#x27;\/api\/users\/csv&#x27;, {\n        method: &#x27;POST&#x27;,\n        headers: {\n            &#x27;Content-Type&#x27;: &#x27;application\/json&#x27;,\n            &#x27;X-CSRF-Token&#x27;: csrfToken\n        },\n        body: JSON.stringify({\n            search: params.search.value,\n            order: params.order,\n            columns: params.columns\n        })\n    });\n\n    if (!response.ok) {\n        alert(&#x27;CSV\u306e\u4f5c\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002&#x27;);\n        return;\n    }\n\n    const blob = await response.blob();\n    const url = URL.createObjectURL(blob);\n    const link = document.createElement(&#x27;a&#x27;);\n\n    link.href = url;\n    link.download = &#x27;users.csv&#x27;;\n    link.click();\n\n    URL.revokeObjectURL(url);\n}<\/code><\/pre>\n<p>POST\u306b\u3059\u308b\u5834\u5408\u306f\u3001CSRF\u5bfe\u7b56\u3082\u5fd8\u308c\u305a\u306b\u884c\u3044\u307e\u3059\u3002<br \/>\u307e\u305f\u3001CSV\u306e\u4ef6\u6570\u304c\u975e\u5e38\u306b\u591a\u3044\u5834\u5408\u306f\u3001\u540c\u671f\u7684\u306b\u3059\u3050\u8fd4\u3059\u306e\u3067\u306f\u306a\u304f\u3001\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067CSV\u3092\u4f5c\u6210\u3057\u3066\u3001\u5b8c\u4e86\u5f8c\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\u8a2d\u8a08\u3082\u691c\u8a0e\u3057\u307e\u3059\u3002<\/p>\n<h2>\u753b\u9762\u8868\u793a\u7528\u3068CSV\u51fa\u529b\u7528\u306e\u5024\u3092\u5206\u3051\u308b<\/h2>\n<p>\u753b\u9762\u306b\u306f\u300c\u6709\u52b9\u300d\u300c\u505c\u6b62\u300d\u306e\u3088\u3046\u306a\u8868\u793a\u7528\u30e9\u30d9\u30eb\u3092\u51fa\u3057\u3001\u30c7\u30fc\u30bf\u4e0a\u306f<code>active<\/code>\u3084<code>stopped<\/code>\u3092\u6301\u3063\u3066\u3044\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>CSV\u306b\u3069\u3061\u3089\u3092\u51fa\u3057\u305f\u3044\u304b\u3092\u6c7a\u3081\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u753b\u9762\u8868\u793a\u3068\u540c\u3058\u5024\u3092CSV\u306b\u51fa\u3059\u5834\u5408\u306f\u3001<code>render<\/code>\u3067<code>display<\/code>\u4ee5\u5916\u306e\u5024\u3082\u610f\u8b58\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-javascript\">const STATUS_LABELS = {\n    active: &#x27;\u6709\u52b9&#x27;,\n    stopped: &#x27;\u505c\u6b62&#x27;\n};\n\nnew DataTable(&#x27;#usersTable&#x27;, {\n    data: users,\n    columns: [\n        {\n            data: &#x27;status&#x27;,\n            title: &#x27;\u30b9\u30c6\u30fc\u30bf\u30b9&#x27;,\n            render: function (data, type) {\n                if (type === &#x27;display&#x27; || type === &#x27;export&#x27;) {\n                    return STATUS_LABELS[data] ?? &#x27;\u4e0d\u660e&#x27;;\n                }\n\n                return data;\n            }\n        }\n    ],\n    layout: {\n        topStart: {\n            buttons: [\n                {\n                    extend: &#x27;csvHtml5&#x27;,\n                    text: &#x27;CSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9&#x27;,\n                    exportOptions: {\n                        orthogonal: &#x27;export&#x27;\n                    }\n                }\n            ]\n        }\n    }\n});<\/code><\/pre>\n<p><code>exportOptions.orthogonal<\/code>\u3092\u4f7f\u3046\u3068\u3001CSV\u51fa\u529b\u6642\u306b<code>render<\/code>\u3078\u6e21\u3059\u7a2e\u985e\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<br \/>\u8868\u793a\u7528\u3001\u691c\u7d22\u7528\u3001\u30bd\u30fc\u30c8\u7528\u3001CSV\u51fa\u529b\u7528\u3092\u5206\u3051\u305f\u3044\u5834\u5408\u306b\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<h2>CSV\u51fa\u529b\u6642\u306e\u6ce8\u610f\u70b9<\/h2>\n<p>CSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u306f\u3001\u4ee5\u4e0b\u306b\u3082\u6ce8\u610f\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u65e5\u672c\u8a9e\u3092Excel\u3067\u958b\u304f\u306a\u3089<code>bom: true<\/code>\u3092\u691c\u8a0e\u3059\u308b<\/li>\n<li>\u64cd\u4f5c\u5217\u3084\u975e\u8868\u793a\u306b\u3057\u305f\u3044\u5217\u306f<code>exportOptions.columns<\/code>\u3067\u9664\u5916\u3059\u308b<\/li>\n<li>HTML\u3092\u542b\u3080\u5217\u306f\u3001CSV\u306b\u51fa\u3057\u305f\u3044\u5024\u306b\u6574\u3048\u308b<\/li>\n<li><code>serverSide: true<\/code>\u3067\u306f\u30d6\u30e9\u30a6\u30b6\u5074\u306b\u5168\u4ef6\u304c\u306a\u3044<\/li>\n<li>\u5168\u91cfCSV\u306f\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u4f5c\u308b\u65b9\u6cd5\u3068\u3001\u30da\u30fc\u30b8\u3054\u3068\u306b\u53d6\u5f97\u3057\u3066\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3067\u4f5c\u308b\u65b9\u6cd5\u304c\u3042\u308b<\/li>\n<li>\u5927\u91cfCSV\u306f\u30b5\u30fc\u30d0\u30fc\u5074\u3068\u30d6\u30e9\u30a6\u30b6\u5074\u306e\u4e21\u65b9\u3067\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3084\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306b\u6ce8\u610f\u3059\u308b<\/li>\n<li>CSV\u3092Excel\u3067\u958b\u304f\u5834\u5408\u306f\u3001\u6570\u5f0f\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u306b\u3082\u6ce8\u610f\u3059\u308b<\/li>\n<\/ul>\n<p>Buttons\u306eCSV\u51fa\u529b\u3067\u306f\u3001HTML\u3092\u53d6\u308a\u9664\u3044\u305f\u308a\u3001HTML\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u3092\u30c7\u30b3\u30fc\u30c9\u3057\u305f\u308a\u3059\u308b\u305f\u3081\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\u5927\u91cf\u30c7\u30fc\u30bf\u3092\u30d6\u30e9\u30a6\u30b6\u5074\u3067\u51fa\u529b\u3059\u308b\u5834\u5408\u306f\u3001\u5909\u63db\u51e6\u7406\u81ea\u4f53\u304c\u91cd\u304f\u306a\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u5168\u91cf\u3092\u30d6\u30e9\u30a6\u30b6\u5074\u3067\u8aad\u307f\u8fbc\u3093\u3067\u3044\u308b\u4e00\u89a7\u306a\u3089\u3001Buttons\u62e1\u5f35\u306e<code>csvHtml5<\/code>\u3067CSV\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3092\u4ed8\u3051\u3089\u308c\u307e\u3059\u3002<\/p>\n<ul>\n<li>CSV\u51fa\u529b\u306b\u306fButtons\u62e1\u5f35\u3092\u4f7f\u3046<\/li>\n<li>DataTables 2\u7cfb\u3067\u306f<code>layout<\/code>\u306b<code>buttons<\/code>\u3092\u914d\u7f6e\u3059\u308b<\/li>\n<li>\u65e5\u672c\u8a9eCSV\u3092Excel\u3067\u958b\u304f\u306a\u3089<code>bom: true<\/code>\u3092\u691c\u8a0e\u3059\u308b<\/li>\n<li>\u51fa\u529b\u5bfe\u8c61\u5217\u306f<code>exportOptions.columns<\/code>\u3067\u5236\u5fa1\u3059\u308b<\/li>\n<li>\u691c\u7d22\u6761\u4ef6\u3092\u7121\u8996\u3057\u3066\u51fa\u529b\u3059\u308b\u306a\u3089<code>exportOptions.modifier.search: &#x27;none&#x27;<\/code>\u3092\u4f7f\u3046<\/li>\n<li><code>serverSide: true<\/code>\u3067\u306f\u30d6\u30e9\u30a6\u30b6\u5074\u306b\u73fe\u5728\u30da\u30fc\u30b8\u5206\u3057\u304b\u306a\u3044\u3053\u3068\u304c\u3042\u308b<\/li>\n<li>\u30b5\u30fc\u30d0\u30fc\u5074\u51e6\u7406\u3067\u5168\u91cfCSV\u3092\u51fa\u3059\u306a\u3089\u3001CSV\u5c02\u7528API\u3092\u4f5c\u308b\u65b9\u6cd5\u304c\u3042\u308b<\/li>\n<li>\u30b5\u30fc\u30d0\u30fc\u5074\u306e\u30e1\u30e2\u30ea\u304c\u6c17\u306b\u306a\u308b\u5834\u5408\u306f\u3001\u65e2\u5b58\u306e\u30da\u30fc\u30b8\u30f3\u30b0API\u3092\u7e70\u308a\u8fd4\u3057\u547c\u3073\u51fa\u3057\u3066\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3067CSV\u3092\u7d44\u307f\u7acb\u3066\u308b\u65b9\u6cd5\u3082\u3042\u308b<\/li>\n<li>\u691c\u7d22\u6761\u4ef6\u3084\u4e26\u3073\u66ff\u3048\u6761\u4ef6\u3092CSV API\u3001\u307e\u305f\u306f\u30da\u30fc\u30b8\u30f3\u30b0API\u3078\u6e21\u3057\u3001\u753b\u9762\u3068\u540c\u3058\u6761\u4ef6\u3067CSV\u3092\u751f\u6210\u3059\u308b<\/li>\n<\/ul>\n<p>\u5c0f\u898f\u6a21\u306a\u4e00\u89a7\u306a\u3089Buttons\u306eCSV\u30dc\u30bf\u30f3\u3060\u3051\u3067\u5341\u5206\u3067\u3059\u3002<br \/>\u4e00\u65b9\u3001\u5927\u91cf\u30c7\u30fc\u30bf\u3084<code>serverSide: true<\/code>\u306e\u753b\u9762\u3067\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u3067CSV\u3092\u4f5c\u308b\u3001\u30da\u30fc\u30b8\u3054\u3068\u306b\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3067\u96c6\u3081\u308b\u3001\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u4f5c\u308b\u3001\u3068\u3044\u3063\u305f\u9078\u629e\u80a2\u3092\u30c7\u30fc\u30bf\u91cf\u306b\u5fdc\u3058\u3066\u4f7f\u3044\u5206\u3051\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>DataTables\u306eButtons\u62e1\u5f35\u3067CSV\u30dc\u30bf\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5\u3068\u3001serverSide\u6709\u52b9\u6642\u306b\u5168\u91cfCSV\u3092\u51fa\u3059\u8a2d\u8a08\u306e\u8003\u3048\u65b9\u3092\u307e\u3068\u3081\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[10],"tags":[24,23,13,14],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-buttons","tag-csv","tag-datatables","tag-javascript"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tech-undefined.com\/index.php?rest_route=\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech-undefined.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech-undefined.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech-undefined.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech-undefined.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=118"}],"version-history":[{"count":4,"href":"https:\/\/www.tech-undefined.com\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":134,"href":"https:\/\/www.tech-undefined.com\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions\/134"}],"wp:attachment":[{"href":"https:\/\/www.tech-undefined.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech-undefined.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech-undefined.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}