libxlsxwriter
Loading...
Searching...
No Matches
tab_colors.c
<< background.c diagonal_border.c >>

Example of how to set Excel worksheet tab colors.

/*
* Example of how to set Excel worksheet tab colors using libxlsxwriter.
*
* Copyright 2014-2024, John McNamara, jmcnamara@cpan.org
*
*/
#include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = workbook_new("tab_colors.xlsx");
/* Set up some worksheets. */
lxw_worksheet *worksheet1 = workbook_add_worksheet(workbook, NULL);
lxw_worksheet *worksheet2 = workbook_add_worksheet(workbook, NULL);
lxw_worksheet *worksheet3 = workbook_add_worksheet(workbook, NULL);
lxw_worksheet *worksheet4 = workbook_add_worksheet(workbook, NULL);
/* Set the tab colors. */
worksheet_set_tab_color(worksheet3, 0xFF9900); /* Orange. */
/* worksheet4 will have the default color. */
worksheet_write_string(worksheet4, 0, 0, "Hello", NULL);
workbook_close(workbook);
return 0;
}
@ LXW_COLOR_GREEN
Definition: format.h:197
@ LXW_COLOR_RED
Definition: format.h:218
Struct to represent an Excel workbook.
Definition: workbook.h:293
Struct to represent an Excel worksheet.
Definition: worksheet.h:2115
lxw_workbook * workbook_new(const char *filename)
Create a new workbook object.
lxw_error workbook_close(lxw_workbook *workbook)
Close the Workbook object and write the XLSX file.
lxw_worksheet * workbook_add_worksheet(lxw_workbook *workbook, const char *sheetname)
Add a new worksheet to a workbook.
void worksheet_set_tab_color(lxw_worksheet *worksheet, lxw_color_t color)
Set the color of the worksheet tab.
lxw_error worksheet_write_string(lxw_worksheet *worksheet, lxw_row_t row, lxw_col_t col, const char *string, lxw_format *format)
Write a string to a worksheet cell.