<legend id='lJAAJ'><style id='lJAAJ'><dir id='lJAAJ'><q id='lJAAJ'></q></dir></style></legend>
    <bdo id='lJAAJ'></bdo><ul id='lJAAJ'></ul>

        <small id='lJAAJ'></small><noframes id='lJAAJ'>

        <i id='lJAAJ'><tr id='lJAAJ'><dt id='lJAAJ'><q id='lJAAJ'><span id='lJAAJ'><b id='lJAAJ'><form id='lJAAJ'><ins id='lJAAJ'></ins><ul id='lJAAJ'></ul><sub id='lJAAJ'></sub></form><legend id='lJAAJ'></legend><bdo id='lJAAJ'><pre id='lJAAJ'><center id='lJAAJ'></center></pre></bdo></b><th id='lJAAJ'></th></span></q></dt></tr></i><div id='lJAAJ'><tfoot id='lJAAJ'></tfoot><dl id='lJAAJ'><fieldset id='lJAAJ'></fieldset></dl></div>
      1. <tfoot id='lJAAJ'></tfoot>
      2. 将 Python 列表导出到 Excel

        时间:2023-09-11
            <bdo id='mYvbJ'></bdo><ul id='mYvbJ'></ul>
              <tbody id='mYvbJ'></tbody>

          • <legend id='mYvbJ'><style id='mYvbJ'><dir id='mYvbJ'><q id='mYvbJ'></q></dir></style></legend>
            <tfoot id='mYvbJ'></tfoot>

              <small id='mYvbJ'></small><noframes id='mYvbJ'>

                  <i id='mYvbJ'><tr id='mYvbJ'><dt id='mYvbJ'><q id='mYvbJ'><span id='mYvbJ'><b id='mYvbJ'><form id='mYvbJ'><ins id='mYvbJ'></ins><ul id='mYvbJ'></ul><sub id='mYvbJ'></sub></form><legend id='mYvbJ'></legend><bdo id='mYvbJ'><pre id='mYvbJ'><center id='mYvbJ'></center></pre></bdo></b><th id='mYvbJ'></th></span></q></dt></tr></i><div id='mYvbJ'><tfoot id='mYvbJ'></tfoot><dl id='mYvbJ'><fieldset id='mYvbJ'></fieldset></dl></div>

                1. 本文介绍了将 Python 列表导出到 Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试通过我在标题处导入的 Win32COM 客户端将列表导出到 excel.我创建的对象编码如下,但我似乎无法让它将每个值导出到电子表格中自己的行.如果我能得到一个好的指针(除了放弃 python !!:D),我将不胜感激.

                  I am trying to export a list to excel via the Win32COM client whihc i have imported at the header. The object i created is coded as below, but I cant seem to get it to export each value to its own row in the spreadsheet. If I can get a good pointer (other than give up python!! :D), I would appreciate it.

                  class XcelExport():
                      def excel(self):
                          app = 'Excel'
                          xl = win32.gencache.EnsureDispatch('%s.Application' % app)
                          ss = xl.Workbooks.Open(r'C:MyFile.xls')
                          sh = ss.ActiveSheet
                          xl.Visible = True
                          sleep(.1)  
                          sh.Cells(1,1).Value = 'Export-to-%s : Items' % app
                          sleep(.1)
                          for i in EventTableRFT:
                              sh.Range("A").Value = i 
                          sh.Cells(i+2,1).Value = "End of the List!"
                  
                  xprt = XcelExport()
                  xprt.excel()
                  

                  推荐答案

                  既然你似乎喜欢我的回答/评论,这里有一个正确的答案:

                  Since you seemed to like my answer/comment, here's an answer proper:

                  Python Excel 拥有您所需要的一切.如果您想要更集成但似乎有限的东西,则有 IronSpread.XLRD 和 XLWT 是很棒的软件包,但它们不支持 *.xlsx 文件.IronSpread 仅适用于 Windows,并且仅支持 '07 和 '10 版本的 Excel.每个都有它的警告.最后,您可以同时使用两者(编辑为 *.xlsx,然后另存为 *.xls(我有人遇到过大 *.xls 文件的速度问题,但我的脚本在 1分钟.)).

                  Python Excel has just about everything you'd ever need. If you want something more integrated but seems limited, there is IronSpread. XLRD and XLWT are great packages, but they don't support *.xlsx files. IronSpread is Windows only and only support '07 and '10 versions of Excel. Each has it's caveats. In the end, you can use both (edit as *.xlsx, then save as to *.xls (I had someone who had speed issues with large *.xls files, but my script wrote 200mb of text from that thing in like 1 minute.)).

                  哦,我肯定会阅读(略读)文档以了解有趣的功能,例如获取 xlrd/xlwt 的细胞类型等.这是值得的,如果只是因为它很短,并且可以节省您进行实验的学习曲线.

                  Oh, and I would definitely read (skim) the documentation for interesting features such as getting the cell types etc of xlrd/xlwt. It's worth it, if only because it's short and will save you the learning curve of experimenting.

                  xlwt 的超短示例:

                  Super short example of xlwt:

                  import xlwt
                  from tempfile import TemporaryFile
                  book = xlwt.Workbook()
                  sheet1 = book.add_sheet('sheet1')
                  
                  supersecretdata = [34,123,4,1234,12,34,12,41,234,123,4,123,1,45123,5,43,61,3,56]
                  
                  for i,e in enumerate(supersecretdata):
                      sheet1.write(i,1,e)
                  
                  name = "random.xls"
                  book.save(name)
                  book.save(TemporaryFile())
                  

                  xlrd 的超短示例:

                  Super short example of xlrd:

                  import xlrd
                  from xlrd import open_workbook
                  book = open_workbook('random.xls')
                  sheet1 = book.sheet_by_index(0)
                  data = []
                  
                  for i in xrange(sheet1.nrows):
                      data.append(sheet1.cell(i,1).value)
                  

                  这篇关于将 Python 列表导出到 Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 discord.py 列出不和谐服务器中的所有成 下一篇:COM:excelApplication.Application.Quit() 保留进程

                  相关文章

                  最新文章

                  <small id='q9YC8'></small><noframes id='q9YC8'>

                    <bdo id='q9YC8'></bdo><ul id='q9YC8'></ul>

                  1. <legend id='q9YC8'><style id='q9YC8'><dir id='q9YC8'><q id='q9YC8'></q></dir></style></legend>

                      <i id='q9YC8'><tr id='q9YC8'><dt id='q9YC8'><q id='q9YC8'><span id='q9YC8'><b id='q9YC8'><form id='q9YC8'><ins id='q9YC8'></ins><ul id='q9YC8'></ul><sub id='q9YC8'></sub></form><legend id='q9YC8'></legend><bdo id='q9YC8'><pre id='q9YC8'><center id='q9YC8'></center></pre></bdo></b><th id='q9YC8'></th></span></q></dt></tr></i><div id='q9YC8'><tfoot id='q9YC8'></tfoot><dl id='q9YC8'><fieldset id='q9YC8'></fieldset></dl></div>
                    1. <tfoot id='q9YC8'></tfoot>