-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathimages.bas
51 lines (38 loc) · 1.43 KB
/
images.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
42
43
44
45
46
47
48
49
50
51
/'
* An example of inserting images into a worksheet using the libxlsxwriter
* library.
*
* 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
/' Create a new workbook and add a worksheet. '/
var workbook = workbook_new("images.xlsx")
var worksheet = workbook_add_worksheet(workbook, NULL)
/' Change some of the column widths for clarity. '/
worksheet_set_column(worksheet, COLS("A:A"), 30, NULL)
/' Insert an image. '/
worksheet_write_string(worksheet, CELL("A2"), "Insert an image in a cell:", NULL)
worksheet_insert_image(worksheet, CELL("B2"), "logo.png")
/' Insert an image offset in the cell. '/
worksheet_write_string(worksheet, CELL("A12"), "Insert an offset image:", NULL)
Dim As lxw_image_options options1
with options1
.x_offset = 15
.y_offset = 10
end with
worksheet_insert_image_opt(worksheet, CELL("B12"), "logo.png", @options1)
/' Insert an image with scaling. '/
worksheet_write_string(worksheet, CELL("A23"), "Insert a scaled image:", NULL)
Dim As lxw_image_options options2
with options2
.x_scale = 0.5
.y_scale = 0.5
End With
worksheet_insert_image_opt(worksheet, CELL("B23"), "logo.png", @options2)
workbook_close(workbook)
return 0
End Function
main()