Tag: ubuntu 14.04

Python:'NoneType'对象没有属性'decompressobj'

我在Ubuntu上使用Python 2.7.11。 我试图用xlrd包在Python中打开一个Excel文件(.xlsx)。 但是,当我尝试使用包中的open_workbook()函数打开我的Excel文件时,出现以下错误: Traceback (most recent call last): File "TileInserter.py", line 15, in <module> book = open_workbook(sheetPath, on_demand=True) File "/usr/local/lib/python2.7/site-packages/xlrd/__init__.py", line 422, in open_workbook ragged_rows=ragged_rows, File "/usr/local/lib/python2.7/site-packages/xlrd/xlsx.py", line 761, in open_workbook_2007_xml zflo = zf.open(component_names['xl/_rels/workbook.xml.rels']) File "/usr/local/lib/python2.7/zipfile.py", line 1010, in open close_fileobj=should_close) File "/usr/local/lib/python2.7/zipfile.py", line 526, in __init__ self._decompressor = zlib.decompressobj(-15) AttributeError: 'NoneType' object has […]

在使用LibreOffice Calc打开文件时,使用apache poi在java中的行3000到3005中写入图像

我使用poi 3.9来创buildxlsx文件,一切正常,直到我的文件长度超过1600行 。 跨过1600行后,我能写数据,但我无法写图像所有图像相互追加在行号1640这是奇怪的,我正在poi从长时间,并select了它的库限制和更新的问题我的诗到3.15但同样的问题,在这里我能够写图像高达2000行,然后我试图poi 3.16但是问题是一样的,但在这里,我可以写图像高达2500行 。 以下是我写图片的代码 private void drawImageOnExcelSheet(XSSFSheet sitePhotosSheet, int row1, int row2, int col1, int col2, String fileName) { try { InputStream is = new FileInputStream(fileName); byte[] bytes = IOUtils.toByteArray(is); int pictureIdx = sitePhotosSheet.getWorkbook().addPicture(bytes,Workbook.PICTURE_TYPE_JPEG); is.close(); CreationHelper helper = sitePhotosSheet.getWorkbook().getCreationHelper(); Drawing drawing = sitePhotosSheet.createDrawingPatriarch(); ClientAnchor anchor = helper.createClientAnchor(); anchor.setAnchorType(AnchorType.MOVE_AND_RESIZE); anchor.setCol1(col1); anchor.setCol2(col2); anchor.setRow1(row1); anchor.setRow2(row2); […]

openpyxl:读取$和。 来自xlsx

我想使用python将xlsx文件转换为TAB分隔的csv。 阅读后,我被指向名为openpyxl的库(下面的代码) def importXLSX(fileName): temp = os.path.basename(fileName).split('.xlsx') tempFileName = os.path.dirname(os.path.abspath(fileName))+"/TEMP_"+temp[0]+".csv" tempFile = open(tempFileName,'w') wb = load_workbook(filename=fileName) ws = wb.worksheets[0] #Get first worksheet for row in ws.rows: #Iterate over rows for cell in row: cellValue = "" if cell.value is not None: cellValue = cell.value tempFile.write(cellValue+'\t') tempFile.write('\n') os.remove(fileName) return tempFileName 我input的文件包含账单数据,但是这个函数将$ 2,000转换为2000,将0.00转换为0 任何想法为什么?

Python或LibreOffice保存用密码encryption的xlsx文件

我正在尝试保存用密码encryption的Excel文件。 我已经尝试遵循https://help.libreoffice.org/Common/Protecting_Content_in上的指导 – 并且完美地工作。 但是,这是在GUI中,但我正在寻找一种解决scheme,在无头模式下使用命令行界面。 我看过那个man libreoffice ,但是在那找不到任何东西。 同样我也看过Python 3库openpyxl的文档,但是我没有发现任何有用的东西。 是否可以使用不需要任何用户交互或X会话的命令行(或Python库)在Ubuntu 14.04 / 16.04上保存使用密码encryption的Excel 2007+文件?