libxlsxwriter
diagonal_border.c
<< tab_colors.c hide_sheet.c >>

Example of how to set a worksheet cell diagonal border.

/*
* A simple formatting example that demonstrates how to add diagonal
* cell borders using the libxlsxwriter library.
*
* Copyright 2014-2020, John McNamara, jmcnamara@cpan.org
*
*/
#include "xlsxwriter.h"
int main() {
/* Create a new workbook and add a worksheet. */
lxw_workbook *workbook = workbook_new("diagonal_border.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
/* Add some diagonal border formats. */
lxw_format *format1 = workbook_add_format(workbook);
lxw_format *format2 = workbook_add_format(workbook);
lxw_format *format3 = workbook_add_format(workbook);
lxw_format *format4 = workbook_add_format(workbook);
worksheet_write_string(worksheet, CELL("B3"), "Text", format1);
worksheet_write_string(worksheet, CELL("B6"), "Text", format2);
worksheet_write_string(worksheet, CELL("B9"), "Text", format3);
worksheet_write_string(worksheet, CELL("B12"), "Text", format4);
workbook_close(workbook);
return 0;
}
workbook_close
lxw_error workbook_close(lxw_workbook *workbook)
Close the Workbook object and write the XLSX file.
LXW_DIAGONAL_BORDER_DOWN
@ LXW_DIAGONAL_BORDER_DOWN
Definition: format.h:172
workbook_new
lxw_workbook * workbook_new(const char *filename)
Create a new workbook object.
LXW_DIAGONAL_BORDER_UP
@ LXW_DIAGONAL_BORDER_UP
Definition: format.h:169
format_set_diag_border
void format_set_diag_border(lxw_format *format, uint8_t style)
Set the diagonal cell border style.
lxw_worksheet
Struct to represent an Excel worksheet.
Definition: worksheet.h:1603
lxw_format
Struct to represent the formatting properties of an Excel format.
Definition: format.h:358
LXW_BORDER_HAIR
@ LXW_BORDER_HAIR
Definition: format.h:313
LXW_DIAGONAL_BORDER_UP_DOWN
@ LXW_DIAGONAL_BORDER_UP_DOWN
Definition: format.h:175
lxw_workbook
Struct to represent an Excel workbook.
Definition: workbook.h:273
format_set_diag_type
void format_set_diag_type(lxw_format *format, uint8_t type)
Set the diagonal cell border type.
format_set_diag_color
void format_set_diag_color(lxw_format *format, lxw_color_t color)
Set the diagonal cell border color.
worksheet_write_string
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.
LXW_COLOR_RED
@ LXW_COLOR_RED
Definition: format.h:217
CELL
#define CELL(cell)
Convert an Excel A1 cell string into a (row, col) pair.
Definition: utility.h:45
workbook_add_worksheet
lxw_worksheet * workbook_add_worksheet(lxw_workbook *workbook, const char *sheetname)
Add a new worksheet to a workbook.
workbook_add_format
lxw_format * workbook_add_format(lxw_workbook *workbook)
Create a new Format object to formats cells in worksheets.