简体   繁体   English

xlrd和xlsxwriter是否都必须是最新版本,才能从.XLSX文件传输单元格值?

[英]Must both xlrd and xlsxwriter be a up-to-date version to capable transfer cell values from .XLSX files?

Must both xlrd and xlsxwriter be of a minimally recent version capable of working upon .xlsx files? xlrd和xlsxwriter是否都必须是能够处理.xlsx文件的最新版本? I am using respective versions of: xlrd 0.7.4 and xlsxwriter 0.6.0. 我正在使用xlrd 0.7.4和xlsxwriter 0.6.0的各个版本。 In a python script file seeking to gather values from 3 worksheets within an .XLSX file and return summed values in a single sheet output .xlsx file, the script reads as 在一个python脚本文件中,该脚本试图从.XLSX文件中的3个工作表中收集值,并在单个工作表输出.xlsx文件中返回求和的值,该脚本的内容为

 import xlrd import xlsxwriter import csv import os from os import walk import glob import shutil import datetime from datetime import datetime os.chdir('S:\\\\Projects\\\\CMP\\\\DataCollectorsWiki\\\\ArchiveofWork\\\\ITC_2007_Group1') root = 'S:\\\\Projects\\\\CMP\\\\DataCollectorsWiki\\\\ArchiveofWork\\\\ITC_2007_Group1' allfiles = [os.path.join(root,f) for root, dirs, files in walk(root) for f in files] ##consolidate all sheets from data workbooks for afile in allfiles: workbook = xlrd.open_workbook(afile) passenger = workbook.sheet_by_index(0) hvyTruck = workbook.sheet_by_index(1) ltTruck = workbook.sheet_by_index(2) 

Again, I am using respective versions of: xlrd 0.7.4 and xlsxwriter 0.6.0. 同样,我使用的是xlrd 0.7.4和xlsxwriter 0.6.0的相应版本。 I have read that it is only the xlrd version 0.9.0 that is able to read .xlsx (Excel2007) or subsequent. 我已经读过,只有xlrd 0.9.0版才能读取.xlsx(Excel2007)或更高版本。 Additionally, I have noticed that the .xlsx files I have been working with - when opened in Notepad - begin with either DI or PK - (PK's are actually ZIP files, I've found out). 另外,我注意到我一直使用的.xlsx文件-在记事本中打开时-以DI或PK开头-(我发现PK实际上是ZIP文件)。

So my 2 questions are - 所以我的两个问题是-

1.must both the xlrd and xlsxwriter be both of a certain vintage (version) to properly extract cell value data from .XLSX files and/or: 1. xlrd和xlsxwriter都必须具有一定的年份(版本),才能从.XLSX文件中正确提取单元格值数据和/或:

  1. can the .xlsx files that begin with "PK" be changed in some way not to have that condition - or is saving back to .xls (Excel '97) encouraged before running the Python script? 是否可以以某种方式更改以“ PK”开头的.xlsx文件,使其不具有该条件-还是在运行Python脚本之前鼓励将其保存回.xls(Excel '97)?

So my 2 questions are... 所以我的两个问题是...

  1. Yes, the minimum version of xlrd must be at least 0.9.0 (as you say yourself) to read xlsx files. 是的,xlrd的最低版本必须至少为0.9.0(如您自己说的那样)才能读取xlsx文件。 It is probably best to use the latest version of xlrd since it will also contain bug fixes. 最好使用最新版本的xlrd,因为它还会包含错误修复程序。 The XlsxWriter module writes files so you don't need any version of that to extract data from an Excel file. XlsxWriter模块写入文件,因此您不需要该文件的任何版本即可从Excel文件中提取数据。 If you want to write an xlsx file then any version of XlsxWriter will do but the latest version has more features and bug fixes. 如果要编写xlsx文件,则可以使用任何版本的XlsxWriter,但最新版本具有更多功能和错误修复。

  2. It isn't easy to convert xlsx to xls with 100% fidelity outside of Excel. 在Excel之外将xlsx转换为具有100%保真度的xls并不容易。

So if you have a choice between trying to automate Excel on Windows to convert files from one format to another or just upgrading xlrd to a more recent version then the latter seems easier. 因此,如果您可以选择在Windows上自动执行Excel以将文件从一种格式转换为另一种格式,或者只是将xlrd升级到更新的版本,则后者似乎更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 xlrd 从 XLSX 单元格获取每个字符格式? - How to get each char format from XLSX cell with xlrd? Python:汇总保存在不同文件夹中的xlsx文件中的值 - Python: summing up values from xlsx files saved in different folders 如何使用python从xlsx文件中的另一列中使用单元格值从一列中减去单元格值 - How to subtract cell values from one column with cell values from another column in xlsx files using python 使用 python 将段从一个 Excel 文件复制到另一个:xlrd 和 xlsxwriter - Copying the segment from one Excel file to another with python: xlrd and xlsxwriter xlsxwriter和xlrd问题-xlsx文件在另一台计算机上另存为ZIP,在另一台计算机上另存为前4个字节 - xlsxwriter & xlrd issue - xlsx file saved as ZIP on one machine, but with other first 4 bytes on another Python xlrd使用日期转换将Excel xlsx解析为csv - Python xlrd parse Excel xlsx to csv with date conversion xlrd&openpyxl获取错误的单元格值(Excel) - xlrd & openpyxl fetch wrong cell values (Excel) XLRD 拆分单元格的逗号分隔值 - XLRD splitting comma separated values of a cell 如何在Python中使用xlrd从单个单元格中获得多个值,并用逗号分隔多个值? - How do I get separate values from a single cell with multiple values in it separated by commas using xlrd in Python? 要求已最新:点入 - Requirement already up-to-date: pip in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM