Setting styles in Openpyxl

As of openpyxl version 1.5.7, I have successfully applied the following worksheet style options… from openpyxl.reader.excel import load_workbook from openpyxl.workbook import Workbook from openpyxl.styles import Color, Fill from openpyxl.cell import Cell # Load the workbook… book = load_workbook(‘foo.xlsx’) # define ws here, in this case I pick the first worksheet in the workbook… # NOTE: … Read more

Python – Converting XLSX to PDF

As my original answer was deleted and is eventually a bit useful, I repost it here. You could do it in 3 steps: excel to pandas: pandas.read_excel pandas to HTML: pandas.DataFrame.to_html HTML to pdf: python-pdfkit (git), python-pdfkit (pypi.org) import pandas as pd import pdfkit df = pd.read_excel(“file.xlsx”) df.to_html(“file.html”) pdfkit.from_file(“file.html”, “file.pdf”) install: sudo pip3.6 install pandas … Read more

Error While Reading Large Excel Files (xlsx) Via Apache POI

Here is an example to read a large xls file using sax parser. public void parseExcel(File file) throws IOException { OPCPackage container; try { container = OPCPackage.open(file.getAbsolutePath()); ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(container); XSSFReader xssfReader = new XSSFReader(container); StylesTable styles = xssfReader.getStylesTable(); XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData(); while (iter.hasNext()) { InputStream stream = iter.next(); processSheet(styles, strings, … Read more

How to export an HTML table as a .xlsx file

A great client-side tool for exporting html tables to xlsx, xls, csv, or txt is TableExport by clarketm (me). It is a simple, easy-to-implement, full-featured library with a bunch of configurable properties and methods. Install $ npm install tableexport Usage TableExport(document.getElementsByTagName(“table”)); // OR using jQuery $(“table”).tableExport(); Documentation Sample apps to get you started TableExport + … Read more

Convert xlsx to csv in Linux with command line

The Gnumeric spreadsheet application comes with a command line utility called ssconvert that can convert between a variety of spreadsheet formats: $ ssconvert Book1.xlsx newfile.csv Using exporter Gnumeric_stf:stf_csv $ cat newfile.csv Foo,Bar,Baz 1,2,3 123.6,7.89, 2012/05/14,, The,last,Line To install on Ubuntu: apt-get install gnumeric To install on Mac: brew install gnumeric

Handling java.lang.OutOfMemoryError when writing to Excel from R

This is a known issue: http://code.google.com/p/rexcel/issues/detail?id=33 While unresolved, the issue page links to a solution by Gabor Grothendieck suggesting that the heap size should be increased by setting the java.parameters option before the rJava package is loaded. (rJava is a dependency of xlsx.) options(java.parameters = “-Xmx1000m”) The value 1000 is the number of megabytes of … Read more