Renamed worksheet_set_row() function.

Renamed worksheet_set_row() function to worksheet_set_row_opt()
for consistency with current and future APIs. The worksheet_set_row()
function is now used without the option.

This is a backward incompatible change.
This commit is contained in:
John McNamara 2016-01-04 00:18:38 +00:00
parent 2c34defdf4
commit 56286656ac
28 changed files with 86 additions and 50 deletions

View File

@ -46,8 +46,8 @@ int main() {
format_set_bold(format);
/* Change the column widths for clarity. */
worksheet_set_column(worksheet, 0, 0, 20, NULL, NULL);
worksheet_set_column(worksheet, 1, 1, 2, NULL, NULL);
worksheet_set_column(worksheet, 0, 0, 20, NULL);
worksheet_set_column(worksheet, 1, 1, 2, NULL);
/* Write some simple text. */
worksheet_write_string(worksheet, 0, 0, "Hello", NULL);

View File

@ -28,7 +28,7 @@ int main() {
/* Set the height of empty rows that we do want to display even if it is */
/* the default height. */
for (row = 1; row <= 6; row++)
worksheet_set_row(worksheet, row, 15, NULL, NULL);
worksheet_set_row(worksheet, row, 15, NULL);
/* Columns can be hidden explicitly. This doesn't increase the file size. */
lxw_row_col_options options = {.hidden = 1};

View File

@ -22,9 +22,9 @@ int main() {
/* Increase the cell size of the merged cells to highlight the formatting. */
worksheet_set_column(worksheet, 1, 3, 12, NULL);
worksheet_set_row(worksheet, 3, 30, NULL, NULL);
worksheet_set_row(worksheet, 6, 30, NULL, NULL);
worksheet_set_row(worksheet, 7, 30, NULL, NULL);
worksheet_set_row(worksheet, 3, 30, NULL);
worksheet_set_row(worksheet, 6, 30, NULL);
worksheet_set_row(worksheet, 7, 30, NULL);
/* Merge 3 cells. */
worksheet_merge_range(worksheet, 3, 1, 3, 3, "Merged Range", merge_format);

View File

@ -41,7 +41,7 @@ int main() {
/* Some sheet formatting. */
worksheet_set_column(worksheet1, 0, 8, 16, NULL);
worksheet_set_row(worksheet1, 0, 20, NULL, NULL);
worksheet_set_row(worksheet1, 0, 20, NULL);
worksheet_set_selection(worksheet1, 4, 3, 4, 3);
/* Some worksheet text to demonstrate scrolling. */
@ -83,7 +83,7 @@ int main() {
/* Some sheet formatting. */
worksheet_set_column(worksheet3, 0, 25, 16, NULL);
worksheet_set_row(worksheet3, 0, 20, NULL, NULL);
worksheet_set_row(worksheet3, 0, 20, NULL);
worksheet_write_string(worksheet3, 0, 0, "", header);
worksheet_set_selection(worksheet3, 4, 3, 4, 3);

View File

@ -1000,6 +1000,7 @@ int8_t worksheet_write_formula_num(lxw_worksheet *worksheet,
const char *formula,
lxw_format *format, double result);
/**
* @brief Set the properties for a row of cells.
*
@ -1007,7 +1008,6 @@ int8_t worksheet_write_formula_num(lxw_worksheet *worksheet,
* @param row The zero indexed row number.
* @param height The row height.
* @param format A pointer to a Format instance or NULL.
* @param options Optional row parameters: hidden, level, collapsed.
*
* The `%worksheet_set_row()` function is used to change the default
* properties of a row. The most common use for this function is to change the
@ -1015,7 +1015,7 @@ int8_t worksheet_write_formula_num(lxw_worksheet *worksheet,
*
* @code
* // Set the height of Row 1 to 20.
* worksheet_set_row(worksheet, 0, 20, NULL, NULL);
* worksheet_set_row(worksheet, 0, 20, NULL);
* @endcode
*
* The other common use for `%worksheet_set_row()` is to set the a @ref
@ -1026,15 +1026,15 @@ int8_t worksheet_write_formula_num(lxw_worksheet *worksheet,
* format_set_bold(bold);
*
* // Set the header row to bold.
* worksheet_set_row(worksheet, 0, 15, bold, NULL);
* worksheet_set_row(worksheet, 0, 15, bold);
* @endcode
*
* If you wish to set the format of a row without changing the height you can
* pass the default row height of #LXW_DEF_ROW_HEIGHT = 15:
*
* @code
* worksheet_set_row(worksheet, 0, LXW_DEF_ROW_HEIGHT, format, NULL);
* worksheet_set_row(worksheet, 0, 15, format, NULL); // Same as above.
* worksheet_set_row(worksheet, 0, LXW_DEF_ROW_HEIGHT, format);
* worksheet_set_row(worksheet, 0, 15, format); // Same as above.
* @endcode
*
* The `format` parameter will be applied to any cells in the row that don't
@ -1043,7 +1043,7 @@ int8_t worksheet_write_formula_num(lxw_worksheet *worksheet,
*
* @code
* // Row 1 has format1.
* worksheet_set_row(worksheet, 0, 15, format1, NULL);
* worksheet_set_row(worksheet, 0, 15, format1);
*
* // Cell A1 in Row 1 defaults to format1.
* worksheet_write_string(worksheet, 0, 0, "Hello", NULL);
@ -1052,6 +1052,25 @@ int8_t worksheet_write_formula_num(lxw_worksheet *worksheet,
* worksheet_write_string(worksheet, 0, 1, "Hello", format2);
* @endcode
*
*/
int8_t worksheet_set_row(lxw_worksheet *worksheet,
lxw_row_t row,
double height,
lxw_format *format);
/**
* @brief Set the properties for a row of cells.
*
* @param worksheet Pointer to a lxw_worksheet instance to be updated.
* @param row The zero indexed row number.
* @param height The row height.
* @param format A pointer to a Format instance or NULL.
* @param options Optional row parameters: hidden, level, collapsed.
*
* The `%worksheet_set_row_opt()` function is the same as
* `worksheet_set_row()` with an additional `options` parameter.
*
* The `options` parameter is a #lxw_row_col_options struct. It has the
* following members but currently only the `hidden` property is supported:
*
@ -1070,10 +1089,11 @@ int8_t worksheet_write_formula_num(lxw_worksheet *worksheet,
* @endcode
*
*/
int8_t worksheet_set_row(lxw_worksheet *worksheet,
int8_t worksheet_set_row_opt(lxw_worksheet *worksheet,
lxw_row_t row,
double height,
lxw_format *format, lxw_row_col_options *options);
lxw_format *format,
lxw_row_col_options *options);
/**
* @brief Set the properties for one or more columns of cells.
@ -1164,8 +1184,10 @@ int8_t worksheet_set_row(lxw_worksheet *worksheet,
* worksheet_write_string(worksheet, 1, 0, "Hello", NULL);
* @endcode
*/
int8_t worksheet_set_column(lxw_worksheet *worksheet, lxw_col_t first_col,
lxw_col_t last_col, double width,
int8_t worksheet_set_column(lxw_worksheet *worksheet,
lxw_col_t first_col,
lxw_col_t last_col,
double width,
lxw_format *format);
/**
@ -1198,8 +1220,10 @@ int8_t worksheet_set_column(lxw_worksheet *worksheet, lxw_col_t first_col,
* @endcode
*
*/
int8_t worksheet_set_column_opt(lxw_worksheet *worksheet, lxw_col_t first_col,
lxw_col_t last_col, double width,
int8_t worksheet_set_column_opt(lxw_worksheet *worksheet,
lxw_col_t first_col,
lxw_col_t last_col,
double width,
lxw_format *format,
lxw_row_col_options *options);

View File

@ -3781,10 +3781,10 @@ worksheet_set_column(lxw_worksheet *self,
}
/*
* Set the properties of a row.
* Set the properties of a row with options.
*/
int8_t
worksheet_set_row(lxw_worksheet *self,
worksheet_set_row_opt(lxw_worksheet *self,
lxw_row_t row_num,
double height,
lxw_format *format, lxw_row_col_options *user_options)
@ -3835,6 +3835,18 @@ worksheet_set_row(lxw_worksheet *self,
return 0;
}
/*
* Set the properties of a row.
*/
int8_t
worksheet_set_row(lxw_worksheet *self,
lxw_row_t row_num,
double height,
lxw_format *format)
{
return worksheet_set_row_opt(self, row_num, height, format, NULL);
}
/*
* Merge a range of cells. The first cell should contain the data and the others
* should be blank. All cells should contain the same format.

View File

@ -21,7 +21,7 @@ int main() {
worksheet_write_string(worksheet, CELL("A10"), "Bar" , NULL);
for (row = 1; row <= 8; row++)
worksheet_set_row(worksheet, row, 15, NULL, NULL);
worksheet_set_row(worksheet, row, 15, NULL);
return workbook_close(workbook);
}

View File

@ -21,7 +21,7 @@ int main() {
worksheet_write_string(worksheet, CELL("A10"), "Bar" , NULL);
for (row = 1; row <= 8; row++)
worksheet_set_row(worksheet, row, 24, NULL, NULL);
worksheet_set_row(worksheet, row, 24, NULL);
return workbook_close(workbook);
}

View File

@ -22,10 +22,10 @@ int main() {
worksheet_write_string(worksheet, CELL("A20"), "Baz" , NULL);
for (row = 1; row <= 8; row++)
worksheet_set_row(worksheet, row, 24, NULL, NULL);
worksheet_set_row(worksheet, row, 24, NULL);
for (row = 10; row <= 19; row++)
worksheet_set_row(worksheet, row, 24, NULL, NULL);
worksheet_set_row(worksheet, row, 24, NULL);
return workbook_close(workbook);
}

View File

@ -18,7 +18,7 @@ int main() {
lxw_format *format1 = workbook_add_format(workbook);
lxw_format *format2 = workbook_add_format(workbook);
worksheet_set_row(worksheet, 0, 30, NULL, NULL);
worksheet_set_row(worksheet, 0, 30, NULL);
format_set_font_name(format1, "Arial");
format_set_bold(format1);

View File

@ -14,7 +14,7 @@ int main() {
lxw_workbook *workbook = new_workbook("test_image12.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
worksheet_set_row(worksheet, 1, 75, NULL, NULL);
worksheet_set_row(worksheet, 1, 75, NULL);
worksheet_set_column(worksheet, 2, 2, 32, NULL);
worksheet_insert_image(worksheet, CELL("C2"), "images/logo.png");

View File

@ -16,7 +16,7 @@ int main() {
lxw_image_options options = {.x_offset = 8, .y_offset = 5};
worksheet_set_row(worksheet, 1, 75, NULL, NULL);
worksheet_set_row(worksheet, 1, 75, NULL);
worksheet_set_column(worksheet, 2, 2, 32, NULL);
worksheet_insert_image_opt(worksheet, CELL("C2"), "images/logo.png", &options);

View File

@ -14,8 +14,8 @@ int main() {
lxw_workbook *workbook = new_workbook("test_image14.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
worksheet_set_row(worksheet, 1, 4.5, NULL, NULL);
worksheet_set_row(worksheet, 2, 35.25, NULL, NULL);
worksheet_set_row(worksheet, 1, 4.5, NULL);
worksheet_set_row(worksheet, 2, 35.25, NULL);
worksheet_set_column(worksheet, 2, 4, 3.29, NULL);
worksheet_set_column(worksheet, 5, 5, 10.71, NULL);

View File

@ -16,8 +16,8 @@ int main() {
lxw_image_options options = {.x_offset = 13, .y_offset = 2};
worksheet_set_row(worksheet, 1, 4.5, NULL, NULL);
worksheet_set_row(worksheet, 2, 35.25, NULL, NULL);
worksheet_set_row(worksheet, 1, 4.5, NULL);
worksheet_set_row(worksheet, 2, 35.25, NULL);
worksheet_set_column(worksheet, 2, 4, 3.29, NULL);
worksheet_set_column(worksheet, 5, 5, 10.71, NULL);

View File

@ -14,7 +14,7 @@ int main() {
lxw_workbook *workbook = new_workbook("test_image17.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
worksheet_set_row(worksheet, 1, 96, NULL, NULL);
worksheet_set_row(worksheet, 1, 96, NULL);
worksheet_set_column(worksheet, 2, 2, 18, NULL);
worksheet_insert_image(worksheet, CELL("C2"), "images/issue32.png");

View File

@ -16,7 +16,7 @@ int main() {
lxw_image_options options = {.x_offset = 5, .y_offset = 5};
worksheet_set_row(worksheet, 1, 96, NULL, NULL);
worksheet_set_row(worksheet, 1, 96, NULL);
worksheet_set_column(worksheet, 2, 2, 18, NULL);
worksheet_insert_image_opt(worksheet, CELL("C2"), "images/issue32.png", &options);

View File

@ -17,7 +17,7 @@ int main() {
lxw_image_options options = {.x_offset = -2, .y_offset = -1};
worksheet_set_column(worksheet, 3, 3, 3.86, NULL);
worksheet_set_row(worksheet, 7, 7.5, NULL, NULL);
worksheet_set_row(worksheet, 7, 7.5, NULL);
worksheet_insert_image_opt(worksheet, CELL("E9"), "images/red.png", &options);

View File

@ -18,8 +18,8 @@ int main() {
worksheet_set_column(worksheet, 3, 3, 3.86, NULL);
worksheet_set_column(worksheet, 4, 4, 1.43, NULL);
worksheet_set_row(worksheet, 7, 7.5, NULL, NULL);
worksheet_set_row(worksheet, 8, 9.75, NULL, NULL);
worksheet_set_row(worksheet, 7, 7.5, NULL);
worksheet_set_row(worksheet, 8, 9.75, NULL);
worksheet_insert_image_opt(worksheet, CELL("E9"), "images/red.png", &options);

View File

@ -19,7 +19,7 @@ int main() {
format_set_bold(bold);
worksheet_set_row(worksheet, 0, 20, bold, NULL);
worksheet_set_row(worksheet, 0, 20, bold);
return workbook_close(workbook);
}

View File

@ -19,7 +19,7 @@ int main() {
format_set_bold(bold);
worksheet_set_row(worksheet, 0, 20, bold, NULL);
worksheet_set_row(worksheet, 0, 20, bold);
worksheet_write_string(worksheet, 0, 0, "Foo", NULL);
return workbook_close(workbook);

View File

@ -19,7 +19,7 @@ int main() {
format_set_bold(bold);
worksheet_set_row(worksheet, 0, 20, bold, NULL);
worksheet_set_row(worksheet, 0, 20, bold);
worksheet_write_string(worksheet, 2, 0, "Foo", NULL);
return workbook_close(workbook);

View File

@ -17,7 +17,7 @@ int main() {
lxw_format *bold = workbook_add_format(workbook);
format_set_bold(bold);
worksheet_set_row(worksheet, 0, 15, bold, NULL);
worksheet_set_row(worksheet, 0, 15, bold);
return workbook_close(workbook);
}

View File

@ -17,7 +17,7 @@ int main() {
lxw_format *bold = workbook_add_format(workbook);
format_set_bold(bold);
worksheet_set_row(worksheet, 0, 15, bold, NULL);
worksheet_set_row(worksheet, 0, 15, bold);
worksheet_write_string(worksheet, 0, 0, "Foo", NULL);

View File

@ -17,7 +17,7 @@ int main() {
lxw_format *bold = workbook_add_format(workbook);
format_set_bold(bold);
worksheet_set_row(worksheet, 4, 15, bold, NULL);
worksheet_set_row(worksheet, 4, 15, bold);
return workbook_close(workbook);
}

View File

@ -27,7 +27,7 @@ int main() {
/* Manually force the format index order for testing. */
_set_default_xf_indices(workbook);
worksheet_set_row(worksheet, 0, 15, bold, NULL);
worksheet_set_row(worksheet, 0, 15, bold);
worksheet_set_column(worksheet, 0, 0, 8.43, italic);
worksheet_write_string(worksheet, 0, 0, "Foo", mixed);

View File

@ -27,7 +27,7 @@ int main() {
/* Manually force the format index order for testing. */
_set_default_xf_indices(workbook);
worksheet_set_row(worksheet, 4, 15, bold, NULL);
worksheet_set_row(worksheet, 4, 15, bold);
worksheet_set_column(worksheet, 2, 2, 8.43, italic);
worksheet_write_string(worksheet, 0, 2, "Foo", NULL);

View File

@ -17,7 +17,7 @@ int main() {
lxw_format *bold = workbook_add_format(workbook);
format_set_bold(bold);
worksheet_set_row(worksheet, 1048575, 15, bold, NULL);
worksheet_set_row(worksheet, 1048575, 15, bold);
return workbook_close(workbook);
}

View File

@ -17,7 +17,7 @@ int main() {
lxw_format *bold = workbook_add_format(workbook);
format_set_bold(bold);
worksheet_set_row(worksheet, 1048575, 15, bold, NULL);
worksheet_set_row(worksheet, 1048575, 15, bold);
worksheet_write_string(worksheet, 1048575, 0, "Bar", NULL);