{"id":48,"date":"2009-01-21T16:54:28","date_gmt":"2009-01-21T07:54:28","guid":{"rendered":"http:\/\/www.zontheworld.com\/blog\/?p=48"},"modified":"2009-08-07T11:46:51","modified_gmt":"2009-08-07T02:46:51","slug":"%e3%82%a8%e3%82%af%e3%82%bb%e3%83%ab%e3%81%a7csv%e3%81%ab%e4%bf%9d%e5%ad%98%e3%81%97%e3%81%a6phpmyadmin%e3%81%b8%e3%82%a4%e3%83%b3%e3%83%9d%e3%83%bc%e3%83%88%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.zontheworld.com\/blog\/archives\/48","title":{"rendered":"\u30a8\u30af\u30bb\u30eb\u3067CSV\u306b\u4fdd\u5b58\u3057\u3066phpMyAdmin\u3078\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u30a8\u30af\u30bb\u30eb\uff08Excel\uff09\u3067\u4f5c\u3063\u305f\u30c7\u30fc\u30bf\u3092 CSV \u3067\u4fdd\u5b58\u3057\u3066 phpMyAdmin \u3078\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u305f\u3081\u306b\u4e0b\u8a18\u306e\u554f\u984c\u3092\u89e3\u6d88\u3059\u308b\u3002<\/p>\n<h3>\uff11\uff0e\u6587\u5b57\u30b3\u30fc\u30c9\u3092UTF-8\u306b\u3059\u308b\u3002<\/h3>\n<p>\u30a8\u30af\u30bb\u30eb\u3067 CSV \u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u4fdd\u5b58\u3059\u308b\u3068\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u306f SJIS \u306b\u306a\u308b\u3002MySQL\u306e\u8a2d\u5b9a\u306b\u3082\u3088\u308b\u304c\u3001\u79c1\u304c\u4f7f\u7528\u3057\u3066\u3044\u308b\u74b0\u5883\u3067\u306f\u57fa\u672c\u7684\u306b\u6587\u5b57\u30b3\u30fc\u30c9\u306fUTF-8\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u4fdd\u5b58\u6642\u306bUTF-8\u3067\u4fdd\u5b58\u3057\u305f\u3044\u3002\u73fe\u72b6\u306f SJIS \u3067\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b CSV \u30d5\u30a1\u30a4\u30eb\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u3092 UTF-8 \u306b\u5909\u63db\u3057\u3066\u4fdd\u5b58\u3057\u306a\u304a\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\u25a0\u4e0b\u8a18\u3092\u53c2\u8003<br \/>\n<a href=\"http:\/\/pf.moe-nifty.com\/100\/2008\/01\/excelutf8csv_f367.html\" class=\"note\">100\u5e74\u30d0\u30ea\u30a2: Excel\u30c7\u30fc\u30bf\u3092UTF-8\u306aCSV\uff08;\u533a\u5207\u308a\uff09\u3067\u4fdd\u5b58\u3059\u308b<\/a><\/p>\n<h3>\uff12\uff0e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u56f2\u3080\u3002<\/h3>\n<p>phpMyAdmin \u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u56f2\u3044\u8a18\u53f7\u304c\u300c\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\uff08\u201d\uff09\u300d\u306b\u306a\u3063\u3066\u3044\u308b\u304c\u3001\u30a8\u30af\u30bb\u30eb\u3067 CSV \u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u4fdd\u5b58\u3057\u3066\u3082\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u56f2\u3063\u3066\u304f\u308c\u306a\u3044\u3002\u3064\u3044\u3067\u306b\u3001phpMyAdmin \u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u533a\u5207\u308a\u8a18\u53f7\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306f\u300c\u30bb\u30df\u30b3\u30ed\u30f3\uff08\uff1b\uff09\u300d\u306b\u306a\u3063\u3066\u3044\u308b\u3051\u3069\u3001\u30a8\u30af\u30bb\u30eb\u3067\u4fdd\u5b58\u3059\u308b\u3068\u300c\u30ab\u30f3\u30de\uff08\uff0c\uff09\u300d\u3067\u4fdd\u5b58\u3055\u308c\u308b\u306e\u3067\u3001\u30bb\u30df\u30b3\u30ed\u30f3\u3067\u4fdd\u5b58\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308b\u3068\u3072\u3068\u624b\u9593\u306a\u304f\u306a\u3063\u3066\u3046\u308c\u3057\u3044\u3002<\/p>\n<p>\u25a0\u4e0b\u8a18\u306e\u89e3\u7b54\u756a\u53f7 No.3 \u3092\u53c2\u8003<br \/>\n<a href=\"http:\/\/okwave.jp\/qa1663314.html\" class=\"note\">\uff23\uff33\uff36\u5f62\u5f0f\u3067\u306e\u4fdd\u5b58\u6642\u306b\u201d\u6587\u5b57\u5217\u5f15\u7528\u7b26\u201d\u306b\u3057\u305f\u3044\uff08\u30a8\u30af\u30bb\u30eb\uff09 -OKWave<\/a><\/p>\n<h3>\uff11\uff0e\u3068 \uff12\uff0e\u306e\u4e21\u65b9\u3092\u517c\u306d\u5099\u3048\u305f VBA \u30de\u30af\u30ed<\/h3>\n<p>\u3053\u306e\u4e8c\u3064\u306e\u30de\u30af\u30ed\u3092\u5408\u4f53\u3055\u305b\u3066\u3001\u5c11\u3005\u5909\u66f4\u3057\u305f\u3089\u51fa\u6765\u308b\u3002<\/p>\n<p><!--more--><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nSub CSVExport_W_Qt_UTF8()\r\n' **********************************\r\n'              \u521d\u671f\u8a2d\u5b9a\r\n' **********************************\r\n\r\n' \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5909\u6570\u306e\u5b9a\u7fa9\r\n    Dim file_source As Object\r\n    Dim file_target As Object\r\n\r\n    Dim code_source As String\r\n    Dim code_target As String\r\n    Dim char_temp   As String\r\n\r\n' \u6587\u5b57\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\r\n    code_source = &quot;Shift_JIS&quot;\r\n    code_target = &quot;UTF-8&quot;\r\n\r\n' \u8868\u793a\u7121\u52b9\r\n    Application.DisplayAlerts = False\r\n\r\n\r\n' **********************************\r\n'          CSV\u30d5\u30a1\u30a4\u30eb\u306e\u4fdd\u5b58\r\n' **********************************\r\n\r\n   Dim Fname As String\r\n   Dim usedRng As Range\r\n   Dim i As Long, j As Long\r\n   Dim buf As String\r\n   Dim Fno As Integer\r\n   Const Qt As String = &quot;&quot;&quot;&quot;\r\n   Fname = Application.InputBox(&quot;\u51fa\u529b\u540d\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;, Type:=2)\r\n   If VarType(Fname) = vbBoolean Or Fname = &quot;&quot; Then Exit Sub\r\n   If InStr(Fname, &quot;.csv&quot;) = 0 Then Fname = Fname &amp; &quot;.csv&quot;\r\n   Fno = FreeFile()\r\n   Open Fname For Output As #Fno\r\n   With ActiveSheet\r\n      Set usedRng = .UsedRange\r\n      On Error Resume Next\r\n      For i = 1 To usedRng.Rows.Count\r\n         For j = 1 To usedRng.Columns.Count\r\n            If Not IsEmpty(usedRng.Cells(i, j)) Then\r\n               buf = buf &amp; &quot;;&quot; &amp; Qt &amp; usedRng.Cells(i, j).Value &amp; Qt\r\n               Else\r\n               buf = buf &amp; &quot;;&quot;\r\n            End If\r\n         Next j\r\n         Print #Fno, Mid$(buf, 2)\r\n         buf = &quot;&quot;\r\n      Next i\r\n      On Error GoTo 0\r\n   End With\r\n   Close #Fno\r\n   Beep\r\n\r\n' **********************************\r\n'      CSV\u30d5\u30a1\u30a4\u30eb\u3092UTF-8\u306b\u5909\u63db\r\n' **********************************\r\n   \r\n' ADODB.Stream\u3092\u53c2\u7167\r\n    Set file_source = CreateObject(&quot;ADODB.Stream&quot;)\r\n\r\n' CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\r\n    With file_source\r\n        .Charset = code_source\r\n        .Open\r\n        .LoadFromFile Fname\r\n        char_temp = .ReadText\r\n    End With\r\n\r\n' CSV\u30d5\u30a1\u30a4\u30eb\u306e\u66f8\u304d\u51fa\u3057\r\n    Set file_target = CreateObject(&quot;ADODB.Stream&quot;)\r\n    With file_target\r\n        .Charset = code_target\r\n        .Open\r\n        .WriteText char_temp\r\n    End With\r\n   \r\n' \u6587\u5b57\u30b3\u30fc\u30c9\u306e\u5909\u63db\r\n    file_source.copyto file_target\r\n    file_target.savetofile Fname, 2\r\n\r\nEnd Sub\r\n<\/pre>\n<p>\u4f7f\u3048\u308c\u3070OK\u3068\u3044\u3046\u30ec\u30d9\u30eb\u306e\u30c4\u30fc\u30eb\u306a\u306e\u3067\u3001\u672c\u5f53\u306b\u5408\u4f53\u3055\u305b\u305f\u3060\u3051\u3067\u7d71\u4e00\u611f\u304c\u5168\u304f\u306a\u3044\u304c\u554f\u984c\u306a\u304f\u52d5\u304f\u3002<\/p>\n<p>\u30d5\u30a3\u30fc\u30eb\u30c9\u5185\u306e\u30c7\u30fc\u30bf\u306e\u30a8\u30b9\u30b1\u30fc\u30d7\u306f\u3057\u3066\u3044\u306a\u3044\u70b9\u306b\u6ce8\u610f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a8\u30af\u30bb\u30eb\uff08Excel\uff09\u3067\u4f5c\u3063\u305f\u30c7\u30fc\u30bf\u3092 CSV \u3067\u4fdd\u5b58\u3057\u3066 phpMyAdmin \u3078\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u305f\u3081\u306b\u4e0b\u8a18\u306e\u554f\u984c\u3092\u89e3\u6d88\u3059\u308b\u3002 \uff11\uff0e\u6587\u5b57\u30b3\u30fc\u30c9\u3092UTF-8\u306b\u3059\u308b\u3002 \u30a8\u30af\u30bb\u30eb\u3067 CSV \u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u4fdd\u5b58\u3059\u308b\u3068\u3001\u6587\u5b57\u30b3\u30fc\u30c9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[35,34],"_links":{"self":[{"href":"https:\/\/www.zontheworld.com\/blog\/wp-json\/wp\/v2\/posts\/48"}],"collection":[{"href":"https:\/\/www.zontheworld.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zontheworld.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zontheworld.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zontheworld.com\/blog\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":0,"href":"https:\/\/www.zontheworld.com\/blog\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zontheworld.com\/blog\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zontheworld.com\/blog\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zontheworld.com\/blog\/wp-json\/wp\/v2\/tags?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}