Top-level functions¶
顶级功能¶
-
load(index=1, header=1, chunksize=5000)¶
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.
将活动工作簿中的选定单元格加载到 pandas DataFrame 中。如果选择的单个单元格有相邻单元格,则该单元格区域会自动展开(通过当前区域)并转化为 pandas DataFrame。如果没有安装 pandas,则会以嵌套列表的形式返回值。Note 备注
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.
只能在 Jupyter 笔记本等交互环境中使用!请勿在脚本中使用,因为它依赖于活动本。Parameters¶
参数¶- indexbool or int, default 1
indexbool 或 int,默认为 1 Defines the number of columns on the left that will be turned into the DataFrame’s index
定义将转化为 DataFrame 索引的左侧列数- headerbool or int, default 1
headerbool 或 int,默认为 1 Defines the number of rows at the top that will be turned into the DataFrame’s columns
定义将转换为 DataFrame 列的顶部行数- chunksizeint, default 5000
chunksize整数,默认为 5000 Chunks the loading of big arrays.
分块加载大数组。
Examples¶
示例¶>>> import xlwings as xw >>> xw.load()
Changed in version 0.23.1.
已在 0.23.1 版中更改。- indexbool or int, default 1
-
view(obj, sheet=None, table=True, chunksize=5000)¶
view(obj、sheet=None、table=True、chunksize=5000)¶ Opens a new workbook and displays an object on its first sheet by default. If you provide a sheet object, it will clear the sheet before displaying the object on the existing sheet.
打开一个新工作簿,默认情况下在其第一个工作表上显示一个对象。如果提供工作表对象,则会先清除工作表,然后再在现有工作表上显示对象。Note 备注
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.
只能在 Jupyter 笔记本等交互环境中使用!请勿在脚本中使用,因为它取决于活动本。Parameters¶
参数¶- objany type with built-in converter
obj任何内置转换器的类型 the object to display, e.g. numbers, strings, lists, numpy arrays, pandas DataFrames
要显示的对象,例如数字、字符串、列表、numpy 数组、pandas DataFrames- sheetSheet, default None
sheet工作表,默认为无。 Sheet object. If none provided, the first sheet of a new workbook is used.
工作表对象。如果没有提供,则使用新工作簿的第一个工作表。- tablebool, default True
table布尔,默认为 True If your object is a pandas DataFrame, by default it is formatted as an Excel Table
如果对象是 pandas DataFrame,默认情况下它的格式是 Excel 表格- chunksizeint, default 5000
chunksize整数,默认为 5000 Chunks the loading of big arrays.
分块加载大数组。
Examples¶
示例¶>>> 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)
Changed in version 0.22.0.
已在 0.22.0 版中更改。- objany type with built-in converter