顶层函数

load(index=1, header=1, chunksize=5000)

Loads the selected cell(s) of the active workbook into a pandas DataFrame. If you select a single cell that has adjacent cells, the range is auto-expanded (via current region) and turned into a pandas DataFrame. If you don't have pandas installed, it returns the values as nested lists.

备注

Only use this in an interactive context like e.g. a Jupyter notebook! Don't use this in a script as it depends on the active book.

参数

indexbool or int, default 1

Defines the number of columns on the left that will be turned into the DataFrame's index

headerbool or int, default 1

Defines the number of rows at the top that will be turned into the DataFrame's columns

chunksizeint, default 5000

Chunks the loading of big arrays.

示例

>>> import xlwings as xw
>>> xw.load()

See also: view

在 0.23.1 版本发生变更.

view(obj, sheet=None, table=True, chunksize=5000)

缺省情况下会创建一个新的工作簿并在第一个工作表上显示一个对象。如果提供了一个工作表对象,在显示对象之前会清除工作表里面的内容。

备注

Only use this in an interactive context like e.g., a Jupyter notebook! Don't use this in a script as it depends on the active book.

参数

objany type with built-in converter

the object to display, e.g. numbers, strings, lists, numpy arrays, pandas DataFrames

sheetSheet, default None

工作表对象。如果没有提供这个参数,会使用一个新建工作簿的第一个工作表。

tablebool类型, 缺省值为True

If your object is a pandas DataFrame, by default it is formatted as an Excel Table

chunksizeint, default 5000

Chunks the loading of big arrays.

示例

>>> import xlwings as xw
>>> import pandas as pd
>>> import numpy as np
>>> df = pd.DataFrame(np.random.rand(10, 4), columns=['a', 'b', 'c', 'd'])
>>> xw.view(df)

See also: load

在 0.22.0 版本发生变更.