Worksheet 接口
工作表接口代表工作簿中的单个工作表,提供单元格操作、格式化和工作表管理的全面功能。
类
-
class oo::iWorksheet
用于单元格操作、格式化和工作表配置的主要工作表接口。
尺寸和基本信息
-
int min_row() const
获取最小行号。
- 返回:
最小行号
-
int min_col() const
获取最小列号
- 返回:
最小列号
-
int max_row() const
获取最大行号
- 返回:
最大行号
-
int max_col() const
获取最大列号
- 返回:
最大列号
-
const char *name() const
获取工作表名称
- 返回:
工作表名称
-
bool set_name(const char *newname)
设置工作表名称
- 参数:
newname -- 工作表新名称
- 返回:
成功返回 true,名称无效或重复返回 false
-
SheetTypeEnum sheet_type() const
获取工作表类型
- 返回:
工作表类型
-
SheetStateEnum get_sheet_state() const
获取工作表的可见性状态。
- 返回:
可见性状态
单元格数据操作
-
CellTypeEnum cell_type(int row, int col) const
获取单元格的数据类型。
- 参数:
row -- 行号
col -- 列号
- 返回:
单元格数据类型
-
bool contains_formula(int row, int col) const
检查单元格是否包含公式。
- 参数:
row -- 行号
col -- 列号
- 返回:
如果单元格包含公式返回 true
-
bool contains_richtext(int row, int col) const
检查单元格是否包含富文本。
- 参数:
row -- 行号
col -- 列号
- 返回:
如果单元格包含富文本返回 true
数据检索方法
-
double get_num(int row, int col) const
从单元格获取数值。
- 参数:
row -- 行号
col -- 列号
- 返回:
数值
-
const char *get_text(int row, int col) const
从单元格获取文本值。
- 参数:
row -- 行号
col -- 列号
- 返回:
文本字符串
-
bool get_boolean(int row, int col) const
从单元格获取布尔值。
- 参数:
row -- 行号
col -- 列号
- 返回:
布尔值
-
double get_datetime(int row, int col) const
从单元格获取日期时间值。
- 参数:
row -- 行号
col -- 列号
- 返回:
以 double 类型表示的日期时间值
-
const char *get_formula_expr(int row, int col) const
从单元格获取公式表达式。
- 参数:
row -- 行号
col -- 列号
- 返回:
公式表达式字符串
-
ErrorCodeEnum get_error(int row, int col) const
从单元格获取错误代码。
- 参数:
row -- 行号
col -- 列号
- 返回:
错误代码
数据设置方法
-
bool set_num(int row, int col, double val)
在单元格中设置数值。
- 参数:
row -- 行号
col -- 列号
val -- 要设置的数值
- 返回:
成功返回 true
-
bool set_text(int row, int col, const char *val)
在单元格中设置文本。
- 参数:
row -- 行号
col -- 列号
val -- 要设置的文本字符串
- 返回:
成功返回 true
-
bool set_boolean(int row, int col, bool b)
在单元格中设置布尔值。
- 参数:
row -- 行号
col -- 列号
b -- 要设置的布尔值
- 返回:
成功返回 true
-
bool set_datetime(int row, int col, double dt)
在单元格中设置日期时间。
- 参数:
row -- 行号
col -- 列号
dt -- 以 double 类型表示的日期时间值
- 返回:
成功返回 true
-
bool set_richtext(int row, int col, iRichtext *rt)
在单元格中设置富文本。
- 参数:
row -- 行号
col -- 列号
rt -- 要设置的富文本对象指针
- 返回:
成功返回 true
-
bool set_error(int row, int col, ErrorCodeEnum code)
在单元格中设置错误值。
- 参数:
row -- 行号
col -- 列号
code -- 要设置的错误代码
- 返回:
成功返回 true
公式操作
-
bool set_formula(int row, int col, const char *expr)
在单元格中设置公式表达式。
- 参数:
row -- 行号
col -- 列号
expr -- 公式表达式
- 返回:
成功返回 true
-
bool set_formula_num(int row, int col, double val)
设置公式的数值结果。
- 参数:
row -- 行号
col -- 列号
val -- 公式结果的数值
- 返回:
成功返回 true
-
bool set_formula_string(int row, int col, const char *s)
设置公式的字符串值结果。
- 参数:
row -- 行号
col -- 列号
s -- 公式结果的字符串值
- 返回:
成功返回 true
-
bool set_formula_boolean(int row, int col, bool b)
设置公式的布尔值结果。
- 参数:
row -- 行号
col -- 列号
b -- 公式结果的布尔值
- 返回:
成功返回 true
-
bool set_formula_datetime(int row, int col, double dt)
设置公式的日期时间值结果。
- 参数:
row -- 行号
col -- 列号
dt -- 公式结果的日期时间值
- 返回:
成功返回 true
-
bool set_formula_error(int row, int col, ErrorCodeEnum code)
设置公式的错误值结果。
- 参数:
row -- 行号
col -- 列号
code -- 公式结果的错误代码
- 返回:
成功返回 true
-
void clear_contents(int begin_row, int begin_col, int end_row, int end_col)
清除范围内的单元格内容。
- 参数:
begin_row -- 开始行号
begin_col -- 开始列号
end_row -- 终止行号
end_col -- 终止列号
样式和格式化
-
void set_cell_style(int row, int col, iStyle *style)
设置单个单元格的样式。
- 参数:
row -- 行号
col -- 列号
style -- 要应用的样式对象指针
-
iStyle *cell_style(int row, int col) const
获取特定单元格的样式。
- 参数:
row -- 行号
col -- 列号
- 返回:
指向单元格样式的指针
警告
为了节省内存,cell_style() 返回的指针指向同一个实例:
Style* s1 = cell_style(1, 1); //s1 is the format of cell (1,1) Style* s2 = cell_style(2, 2); //s1 is the format of cell (2,2)
也就是说,在同一个 worksheet 中,所有调用 cell_style() 的返回值都是最后一次调用的返回值。如果需要各自不同的返回值,请调用 get_style()。
行和列尺寸
-
bool is_default_row_height(int start, int end = 0) const
检查行高是否为默认高度。
- 参数:
start -- 开始行号
end -- 终止行号
- 返回:
如果行高为默认高度返回 true
-
bool get_custom_row_height(int start, int end, double *height, RowHeightUnitEnum unit = ROWHEIGHT_POINTS) const
获取自定义行高。
- 参数:
start -- 开始行号
end -- 终止行号
height -- 存储高度值的指针
unit -- 测量单位
- 返回:
如果行高为自定义高度返回 true
-
void set_custom_row_height(int start, int end, double height, RowHeightUnitEnum unit = ROWHEIGHT_POINTS)
设置自定义行高。
- 参数:
start -- 开始行号
end -- 终止行号
height -- 要设置的高度值
unit -- 测量单位
-
bool is_default_col_width(int start, int end = 0) const
检查列宽是否为默认宽度。
- 参数:
start -- 开始列号
end -- 终止列号(如果为0,仅检查起始列)
- 返回:
如果列宽为默认宽度返回 true
-
bool get_custom_col_width(int start, int end, double *width, ColWidthUnitEnum unit = COLWIDTH_CHARS) const
获取自定义列宽。
- 参数:
start -- 开始列号
end -- 终止列号
width -- 存储宽度值的指针
unit -- 测量单位
- 返回:
如果列宽为自定义列宽返回 true
-
void set_custom_col_width(int start, int end, double width, ColWidthUnitEnum unit = COLWIDTH_CHARS)
设置自定义列宽。
- 参数:
start -- 开始列号
end -- 终止列号
width -- 要设置的宽度值
unit -- 测量单位
行和列样式
-
void remove_row_style(int row)
移除行样式。
- 参数:
row -- 行号
-
void set_row_style(int start_row, int stop_row, iStyle *style)
设置行范围的样式。
- 参数:
start_row -- 开始行号
stop_row -- 终止行号
style -- 要应用的样式对象指针
-
void remove_col_style(int col)
移除列样式。
- 参数:
col -- 列号
可见性控制
检查行是否隐藏。
- 参数:
row -- 行号
- 返回:
如果行隐藏返回 true
设置行可见性。
- 参数:
start_row -- 开始行号
stop_row -- 终止行号
hidden -- true 隐藏,false 显示
检查列是否隐藏。
- 参数:
col -- 列号
- 返回:
如果列隐藏返回 true
设置列可见性。
- 参数:
start_col -- 开始列号
stop_col -- 终止列号
hidden -- true 隐藏,false 显示
行和列操作
-
bool insert_row(int row, int count = 1)
插入行。
- 参数:
row -- 插入的位置
count -- 要插入的行数
- 返回:
成功返回 true
-
bool delete_row(int begin, int end = 0)
删除行。
- 参数:
begin -- 开始行号
end -- 终止行号(如果为 0,仅删除起始行)
- 返回:
成功返回 true
-
bool insert_col(int col, int count = 1)
插入列。
- 参数:
col -- 插入的位置
count -- 要插入的列数
- 返回:
成功返回 true
-
bool delete_col(int begin, int end = 0)
删除列。
- 参数:
begin -- 开始列号
end -- 终止列号(如果为 0,仅删除起始列)
- 返回:
成功返回 true
范围移动操作
-
bool shift_range_down(int start_col, int end_col, int start_row, int count = 1)
向下移动范围。
- 参数:
start_col -- 开始列号
end_col -- 终止列号
start_row -- 开始行号
count -- 要移动的行数
- 返回:
成功返回 true
-
bool shift_range_up(int start_col, int end_col, int start_row, int count = 1)
向上移动范围。
- 参数:
start_col -- 开始列号
end_col -- 终止列号
start_row -- 开始行号
count -- 要移动的行数
- 返回:
成功返回 true
-
bool shift_range_right(int start_row, int end_row, int start_col, int count = 1)
向右移动范围。
- 参数:
start_row -- 开始行号
end_row -- 终止行号
start_col -- 开始列号
count -- 要移动的列数
- 返回:
成功返回 true
-
bool shift_range_left(int start_row, int end_row, int start_col, int count = 1)
向左移动范围。
- 参数:
start_row -- 开始行号
end_row -- 终止行号
start_col -- 开始列号
count -- 要移动的列数
- 返回:
成功返回 true
图像和背景
-
void set_bg_picture(const char *file)
设置背景图片。
- 参数:
file -- 图像文件(含路径)
-
int add_cell_image(const char *file, int start_row, int start_col, int stop_row, int stop_col)
在指定的单元格范围内添加图像。
- 参数:
file -- 图像文件(含路径)
start_row -- 起始行锚点
start_col -- 起始列锚点
stop_row -- 结束行锚点
stop_col -- 结束列锚点
- 返回:
图像标识
-
int add_image_with_two_cells(const char *file, int row1, int col1, int row2, int col2, int offset_x1 = 0, int offset_y1 = 0, int offset_x2 = 0, int offset_y2 = 0)
在工作表中添加图像,以两个单元格定位图像。
- 参数:
file -- 图像文件(含路径)
row1 -- 左上角定位单元格的行号。
col1 -- 左上角定位单元格的列号。
row2 -- 右下角定位单元格的行号。
col2 -- 右下角定位单元格的列号。
offset_x1 -- 左上角定位单元格的水平偏移量(像素值)。
offset_y1 -- 左上角定位单元格的垂直偏移量(像素值)。
offset_x2 -- 右下角定位单元格的水平偏移量(像素值)
offset_y2 -- 右下角定位单元格的垂直偏移量(像素值)。
- 返回:
所添加的图片的ID。
-
int add_image_with_one_cell(const char *file, int row, int col, int width = 0, int height = 0, double scale = 1.0, int offset_x = 0, int offset_y = 0)
在工作表中添加图片,以一个单元格定位图片。如果给定图片的长度和宽度均为 0,则根据 scale 参数计算图片的大小。
- 参数:
file -- 图像文件(含路径)
row -- 定位单元格的行号。
col -- 定位单元格的列号。
width -- 图像的宽度(像素)(0表示使用缩放参数计算大小)。
height -- 图像的高度(像素)(0表示使用缩放参数计算大小)。
scale -- 图像的缩放因子(当宽度和高度都为0时使用)。
offset_x -- 定位单元格内的水平偏移(像素)。
offset_y -- 定位单元格内的垂直偏移(像素)。
- 返回:
所添加的图片的ID。
-
int add_absolute_image(const char *file, int x, int y, int width = 0, int height = 0, double scale = 1.0)
在worksheet中添加图片,以像素坐标定位图片。如果给定的图片宽度和高度均为 0,则使用 scale 参数计算图片的大小。
- 参数:
file -- 图像文件(含路径)
x -- 图片左上角的 x 坐标(像素值)。
y -- 图片左上角的 y 坐标(像素值)。
width -- 图像的宽度(像素)(0表示使用缩放参数计算大小)。
height -- 图像的高度(像素)(0表示使用缩放参数计算大小)。
scale -- 图像的缩放因子(当宽度和高度都为0时使用)。
- 返回:
所添加的图片的ID。
-
int image_num() const
获取工作表中图片的数量。
- 返回:
图片数量。
-
int get_image_id(int index)
根据图像的顺序检索图片标识。
- 参数:
index -- 基于 0 的图片索引。
- 返回:
图片标识
-
ImageAnchorEnum image_anchor_type(int image_id)
获取图片的定位方式。
- 参数:
image_id -- 图片的标识。
- 返回:
ImageAnchorEnum 枚举值。
-
bool get_anchored_cell(int image_id, int *row, int *col)
检索以单个单元格定位的单元格行号和列号。
- 参数:
image_id -- 图片的标识。
row -- 存储行号的指针。
col -- 存储列号的指针。
- 返回:
成功返回 true。
-
bool get_absolute_coord(int image_id, int *x, int *y)
检索以绝对坐标定位的坐标。
- 参数:
image_id -- 图片的标识。
x -- 存储 x 坐标的指针。
y -- 存储 y 坐标的指针。
- 返回:
成功返回 true。
-
void delete_image(int image_id)
根据标识删除图片。
- 参数:
image_id -- 要删除的图片标识。
-
void remove_image(int row, int col)
删除以单个单元格定位的图片。
- 参数:
row -- 定位单元格的行号。
col -- 定位单元格的列号。
-
void remove_absolute_image(int x, int y)
删除以绝对坐标定位的图片。
- 参数:
x -- 图片的 x 坐标 (像素值)。
y -- 图片的 y 坐标 (像素值)。
单元格合并
-
int merged_num() const
获取合并范围的数量。
- 返回:
合并范围的数量
-
bool merged_range(int index, int *start_row, int *start_col, int *stop_row, int *stop_col) const
获取合并范围。
- 参数:
index -- 合并范围的索引
start_row -- 存储合并起始行的指针
start_col -- 存储合并起始列的指针
stop_row -- 存储合并结束行的指针
stop_col -- 存储合并结束列的指针
- 返回:
成功返回 true
-
bool merge(int start_row, int start_col, int stop_row, int stop_col)
合并范围内的单元格。
- 参数:
start_row -- 开始行号
start_col -- 开始列号
stop_row -- 终止行号
stop_col -- 终止列号
- 返回:
成功返回 true
-
bool unmerge(int row, int col)
取消指定位置的单元格合并。
- 参数:
row -- 合并范围内的行索引
col -- 合并范围内的列索引
- 返回:
成功返回 true
表格(列表对象)
-
int tabledef_count() const
获取工作表中表格的数量。
- 返回:
表格的数量
-
const char *get_tabledef_name(int index) const
按索引获取表格名称。
- 参数:
index -- 表格索引
- 返回:
表格名称
-
iTabledef *set_tabledef_name(int index, const char *newName)
设置表格名称。
- 参数:
index -- 表格索引
newName -- 新表格名称
- 返回:
指向表格对象的指针
-
iTabledef *add_tabledef(const char *name, int begin_row, int begin_col, int end_row, int end_col)
向工作表添加新表格。
- 参数:
name -- 表格名称
begin_row -- 开始行号
begin_col -- 开始列号
end_row -- 终止行号
end_col -- 终止列号
- 返回:
指向新表格对象的指针
-
bool delete_tabledef(const char *name)
按名称删除表格。
- 参数:
name -- 要删除的表格名称
- 返回:
成功返回 true
分组和大纲
-
void group_rows(int begin_row, int end_row, bool collapsed = false)
分组行以创建大纲。
- 参数:
begin_row -- 开始行号
end_row -- 终止行号
collapsed -- true 初始化折叠组
-
void ungroup_rows(int begin_row, int end_row)
取消行分组。
- 参数:
begin_row -- 开始行号
end_row -- 终止行号
-
void group_cols(int begin_col, int end_col, bool collapsed = true)
分组列以创建大纲。
- 参数:
begin_col -- 开始列号
end_col -- 终止列号
collapsed -- true 初始化折叠组
-
void ungroup_cols(int begin_col, int end_col)
取消列分组。
- 参数:
begin_col -- 开始列号
end_col -- 终止列号
-
int row_outline_level(int row, bool *collapsed = nullptr) const
获取行大纲级别。
- 参数:
row -- 行号
collapsed -- 存储折叠状态的指针
- 返回:
大纲级别
-
int col_outline_level(int col, bool *collapsed = nullptr) const
获取列大纲级别。
- 参数:
col -- 列号
collapsed -- 存储折叠状态的指针
- 返回:
大纲级别
-
int max_row_outline_level() const
获取最大行大纲级别。
- 返回:
最大大纲级别
-
int max_col_outline_level() const
获取最大列大纲级别。
- 返回:
最大大纲级别
-
void delete_row_outline()
移除所有行大纲。
-
void delete_col_outline()
移除所有列大纲。
-
bool group_summary_below() const
检查摘要行是否在详细信息下方。
- 返回:
如果摘要在下部返回 true
-
void set_group_summary_below(bool below)
设置摘要行位置。
- 参数:
below -- true 摘要在下部,false 在上部
-
bool group_summary_right() const
检查摘要列是否在详细信息右侧。
- 返回:
如果摘要在右侧返回 true
-
void set_group_summary_right(bool right)
设置摘要列位置。
- 参数:
right -- true 摘要在右侧,false 在左侧
超链接
-
bool add_hyperlink(const char *hyperlink, int start_row, int start_col, int end_row, int end_col)
向单元格范围添加超链接。
- 参数:
hyperlink -- URL 或链接地址
start_row -- 开始行号
start_col -- 开始列号
end_row -- 终止行号
end_col -- 终止列号
- 返回:
成功返回 true
-
int hyperlink_num() const
获取超链接数量。
- 返回:
超链接数量
-
int hyperlink_index(int row, int col) const
获取单元格的超链接索引。
- 参数:
row -- 行号
col -- 列号
- 返回:
超链接索引,未找到返回 -1
-
const char *hyperlink(int index, int *start_row, int *start_col, int *end_row, int *end_col)
获取超链接信息。
- 参数:
index -- 超链接索引
start_row -- 存储起始行的指针
start_col -- 存储起始列的指针
end_row -- 存储结束行的指针
end_col -- 存储结束列的指针
- 返回:
超链接地址
-
bool delete_hyperlink(int index)
删除超链接。
- 参数:
index -- 要删除的超链接索引
- 返回:
成功返回 true
工作表保护
-
bool is_protected() const
检查工作表是否受保护。
- 返回:
如果受保护返回 true
-
bool protect(SheetProtectEnum item = PROTECT_DEFAULT, const char *password = nullptr)
保护工作表。
- 参数:
item -- 保护选项
password -- 可选密码
- 返回:
成功返回 true
-
void unprotect()
取消工作表保护。
-
bool protect_range(int start_row, int start_col, int end_row, int end_col)
保护特定单元格范围。
- 参数:
start_row -- 开始行号
start_col -- 开始列号
end_row -- 终止行号
end_col -- 终止列号
- 返回:
成功返回 true
-
bool set_editable_range(int start_row, int start_col, int end_row, int end_col)
在受保护的工作表上允许编辑特定范围。
- 参数:
start_row -- 开始行号
start_col -- 开始列号
end_row -- 终止行号
end_col -- 终止列号
- 返回:
成功返回 true
-
int editable_range_count() const
获取可编辑范围的数量。
- 返回:
可编辑范围数量
-
const char *get_editable_range(int index, int *start_row = nullptr, int *start_col = nullptr, int *stop_row = nullptr, int *stop_col = nullptr) const
获取可编辑范围的信息。
- 参数:
index -- 可编辑范围的索引
start_row -- 存储起始行的指针
start_col -- 存储起始列的指针
stop_row -- 存储结束行的指针
stop_col -- 存储结束列的指针
- 返回:
范围名称
-
bool delete_editable_range(int index)
删除一个可编辑范围。
- 参数:
index -- 要删除的可编辑范围索引
- 返回:
成功返回 true
视图设置
-
int zoom() const
获取工作表缩放级别。
- 返回:
缩放百分比
-
void set_zoom(int zoom)
设置工作表缩放级别。
- 参数:
zoom -- 缩放百分比
-
bool right_to_left() const
检查是否启用从右到左显示。
- 返回:
如果从右到左返回 true
-
void set_right_to_left(bool right_to_left = true)
设置从右到左显示模式。
- 参数:
right_to_left -- true 从右到左,false 从左到右
-
void topleft_cell(int *row, int *col) const
获取左上角可见单元格。
- 参数:
row -- 存储行索引的指针
col -- 存储列索引的指针
-
void set_topleft_cell(int row, int col)
设置左上角可见单元格。
- 参数:
row -- 行号
col -- 列号
-
void active_cell(int *row, int *col) const
获取活动单元格位置。
- 参数:
row -- 存储行索引的指针
col -- 存储列索引的指针
-
void set_active_cell(int row, int col)
设置活动单元格。
- 参数:
row -- 行号
col -- 列号
-
void split_cell(int *row, int *col) const
获取拆分位置。
- 参数:
row -- 存储拆分行的指针
col -- 存储拆分列的指针
-
void set_split_cell(int row, int col)
设置拆分位置。
- 参数:
row -- 拆分行索引
col -- 拆分列索引
-
bool display_gridlines() const
检查是否显示网格线。
- 返回:
如果网格线可见返回 true
-
void set_display_gridlines(bool show = true)
设置网格线可见性。
- 参数:
show -- true 显示网格线,false 隐藏
分页符
-
int row_break_count() const
获取行分页符数量。
- 返回:
行分页符数量
-
int row_break(int index) const
获取行分页符位置。
- 参数:
index -- 分页符索引
- 返回:
分页符的行索引
-
bool set_row_break(int row, bool pageBreak = true)
设置行分页符。
- 参数:
row -- 分页符的行索引
pageBreak -- true 为分页符,false 为手动分页符
- 返回:
成功返回 true
-
int col_break_count() const
获取列分页符数量。
- 返回:
列分页符数量
-
int col_break(int index) const
获取列分页符位置。
- 参数:
index -- 分页符索引
- 返回:
分页符列索引
-
bool set_col_break(int col, bool pageBreak = true)
设置列分页符。
- 参数:
col -- 分页符的列索引
pageBreak -- true 为分页符,false 为手动分页符
- 返回:
成功返回 true
打印设置
-
bool print_gridlines() const
检查是否打印网格线。
- 返回:
如果打印网格线返回 true
-
void set_print_gridlines(bool print = true)
设置网格线打印。
- 参数:
print -- true 打印网格线
-
bool print_headings() const
检查是否打印标题。
- 返回:
如果打印标题返回 true
-
void set_print_headings(bool print = false)
设置标题打印。
- 参数:
print -- true 打印标题
-
bool h_centered_printing() const
检查是否启用水平居中打印。
- 返回:
如果水平居中返回 true
-
void set_h_centered_printing(bool centered = true)
设置水平居中打印。
- 参数:
centered -- true 水平居中
-
bool v_centered_printing() const
检查是否启用垂直居中打印。
- 返回:
如果垂直居中返回 true
-
void set_v_centered_printing(bool centered = true)
设置打印垂直居中。
- 参数:
centered -- true 垂直居中
页边距
-
double left_margin() const
获取左边距。
- 返回:
边距值"
-
void set_left_margin(double value)
设置左边距。
- 参数:
value -- 边距值
-
double right_margin() const
获取右边距。
- 返回:
右边距值
-
void set_right_margin(double value)
设置右边距。
- 参数:
value -- 边距值
-
double top_margin() const
获取上边距。
- 返回:
上边距值
-
void set_top_margin(double value)
设置上边距。
- 参数:
value -- 边距值
-
double bottom_margin() const
获取下边距。
- 返回:
下边距值
-
void set_bottom_margin(double value)
设置下边距。
- 参数:
value -- 边距值
-
double header_margin() const
获取页眉边距。
- 返回:
页眉边距值
-
void set_header_margin(double value)
设置页眉边距。
- 参数:
value -- 边距值
获取页脚边距。
- 返回:
页脚边距值
设置页脚边距。
- 参数:
value -- 边距值
页面设置
-
int paper() const
获取纸张大小代码。
- 返回:
纸张大小代码
-
bool set_paper(int paper_code)
设置纸张大小。
- 参数:
paper_code -- 纸张大小代码
- 返回:
成功返回 true
-
int print_scale() const
获取打印缩放比例。
- 返回:
打印缩放百分比
-
void set_print_scale(int zoom)
设置打印缩放比例。
- 参数:
zoom -- 缩放百分比
-
PageOrientEnum page_orientation() const
获取页面方向。
- 返回:
页面方向
-
void set_page_orientation(PageOrientEnum orientation)
设置页面方向。
- 参数:
orientation -- 要设置的方向
-
PrintErrorEnum print_errors() const
获取错误打印方法。
- 返回:
错误打印方法
-
void set_print_errors(PrintErrorEnum way)
设置错误打印方式。
- 参数:
way -- 错误打印方法
-
int fit_page_height() const
获取适应页面高度设置。
- 返回:
适应的高度页数
-
void set_fit_page_height(int num)
设置适应页面高度。
- 参数:
num -- 适应的高度页数(0禁用)
-
int fit_page_width() const
获取适应页面宽度设置。
- 返回:
适应的宽度页数
-
void set_fit_page_width(int num)
设置适应页面宽度。
- 参数:
num -- 适应的宽度页数(0禁用)
-
int min_row() const
使用示例
#include "oosxl.hxx"
// Get worksheet from workbook
oo::iWorksheet* sheet = workbook->get_sheet(0);
// Set cell values
sheet->set_text(0, 0, "Name");
sheet->set_text(0, 1, "Age");
sheet->set_num(1, 0, 25.5);
sheet->set_boolean(1, 1, true);
// Apply styles
oo::iStyle* headerStyle = workbook->make_normal_style();
headerStyle->set_bold(true);
sheet->set_range_style(0, 0, 0, 1, headerStyle);
// Merge cells
sheet->merge(0, 0, 0, 2);
// Add hyperlink
sheet->add_hyperlink("https://example.com", 2, 0, 2, 0);