Qu

xlsx.write

Builtin index · File I/O

xlsx.write(path, df, [sheet="Sheet1"])

Input: path, df, sheet · Output: no output

What it is

Writes a Table out as a one-worksheet workbook. path (string) is the destination, overwritten if it exists. df (Table) is the data. sheet (string, optional, positional or sheet=, default "Sheet1") names the worksheet inside the file.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
xlsx.write(path, df, [sheet="Sheet1"])
path stringpath (string) is the destination, overwritten if it exists.
df Tabledf (Table) is the data.
sheet string, optional (default "Sheet1")sheet (string, optional, positional or sheet=, default "Sheet1") names the worksheet inside the file.
no outputWrites a Table out as a one-worksheet workbook.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

import xlsx

t = table(city = ("Aachen", "Bonn", "Cologne"), pop = (249, 331, 1087))
xlsx.write("cities.xlsx", t, sheet = "Cities")

print(xlsx.sheets("cities.xlsx"))          # ("Cities")

print(xlsx.read("cities.xlsx"))            # a Table, city/pop

print(xlsx.read("cities.xlsx", headers = false))
output
("Cities")
city      pop
-------  ----
Aachen    249
Bonn      331
Cologne  1087
A        B   
-------  ----
city     pop 
Aachen   249 
Bonn     331 
Cologne  1087

from file-io