{"id":2299,"date":"2015-07-04T17:15:46","date_gmt":"2015-07-04T09:15:46","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2299"},"modified":"2015-07-04T17:15:46","modified_gmt":"2015-07-04T09:15:46","slug":"%e7%94%a8python%e7%9a%84xlrd%e6%a8%a1%e5%9d%97%e5%a4%84%e7%90%86%e6%97%b6%e9%97%b4%e5%8d%95%e5%85%83%e6%a0%bc","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2299.html","title":{"rendered":"\u7528Python\u7684xlrd\u6a21\u5757\u5904\u7406\u65f6\u95f4\u5355\u5143\u683c"},"content":{"rendered":"<p><strong>\u641c\u7d22\u5173\u952e\u5b57\uff1a<\/strong><\/p>\n<ul>\n<li>Python xlrd excel \u65e5\u671f \u65f6\u95f4\u5355\u5143\u683c<\/li>\n<\/ul>\n<p><strong>\u53c2\u8003\u94fe\u63a5\uff1a<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/blog.csdn.net\/orangleliu\/article\/details\/38476881\">http:\/\/blog.csdn.net\/orangleliu\/article\/details\/38476881<\/a><\/li>\n<li><a href=\"http:\/\/www.cnblogs.com\/zhoujie\/p\/python18.html\">http:\/\/www.cnblogs.com\/zhoujie\/p\/python18.html<\/a><\/li>\n<\/ul>\n<p><strong>\u53c2\u8003\u89e3\u7b54\uff1a<\/strong><\/p>\n<pre class=\"lang:default decode:true \">import xlrd\n\ndata = xlrd.open_workbook(EXCEL_PATH)\ntable = data.sheet_by_index(0)\nlines = table.nrows\ncols = table.ncols\nprint u'The total line is %s, cols is %s'%(lines, cols)\n\n# \u8bfb\u53d6\u67d0\u4e2a\u5355\u5143\u683c\ntable.cell(x, y).value\n'''\nx : \u884c\ny : \u5217\n\u884c\/\u5217\u90fd\u662f\u4ece0\u5f00\u59cb\n'''\n\nIn [1]: import xlrd\n\nIn [2]: adata = xlrd.open_workbook('test_xlrd.xlsx')\n\nIn [3]: atable = adata.sheet_by_index(0)\n\nIn [4]: atable.cell(1, 5).value\nOut[4]: 42182.0\n\nIn [5]: xlrd.xldate_as_tuple(atable.cell(1, 5).value, 0)\nOut[5]: (2015, 6, 27, 0, 0, 0)\n\nIn [6]: xlrd.xldate_as_tuple(42182.0, 0)    # \u8f6c\u5316\u4e3a tuple \u5f62\u5f0f\nOut[6]: (2015, 6, 27, 0, 0, 0)\n\nIn [7]: xlrd.xldate.xldate_as_datetime(42182.0, 0)  # \u8f6c\u5316\u4e3a datetime \u5bf9\u8c61\nOut[7]: datetime.datetime(2015, 6, 27, 0, 0)\n\n# \u67e5\u770b\u6e90\u7801(\u5728IPython\u4e2d)\nIn [8]: xlrd.xldate_as_tuple??\nIn [9]: xlrd.xldate.xldate_as_datetime??<\/pre>\n<p>=EOF=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u641c\u7d22\u5173\u952e\u5b57\uff1a Python xlrd excel \u65e5\u671f \u65f6\u95f4\u5355\u5143\u683c \u53c2\u8003\u94fe\u63a5\uff1a http:\/\/blog.csd [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,7,12],"tags":[535,8,536],"class_list":["post-2299","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-programing","category-tools","tag-excel","tag-python","tag-xlrd"],"views":3474,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2299"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2299\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}