-
Notifications
You must be signed in to change notification settings - Fork 4
/
merge_range.bas
41 lines (31 loc) · 1.34 KB
/
merge_range.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/'
* An example of merging cells using libxlsxwriter.
*
* Copyright 2014-2017, John McNamara, [email protected]
*
* translated by Lee June by using https://github.com/retsyo/libxlsxwriter_freebasic
'/
#include "auto_xlsxwriter.bi"
function main() as Integer
Dim as lxw_workbook ptr workbook = workbook_new("merge_range.xlsx")
Dim as lxw_worksheet ptr worksheet = workbook_add_worksheet(workbook, NULL)
Dim as lxw_format ptr merge_format = workbook_add_format(workbook)
/' Configure a format for the merged range. '/
format_set_align(merge_format, LXW_ALIGN_CENTER)
format_set_align(merge_format, LXW_ALIGN_VERTICAL_CENTER)
format_set_bold(merge_format)
format_set_bg_color(merge_format, LXW_COLOR_YELLOW)
format_set_border(merge_format, LXW_BORDER_THIN)
/' 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)
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)
/' Merge 3 cells over two rows. '/
worksheet_merge_range(worksheet, 6, 1, 7, 3, "Merged Range", merge_format)
workbook_close(workbook)
return 0
End Function
main()