Skip to content

Commit 0166fa2

Browse files
authored
Merge pull request #4 from jaakkor2/doc_properties
Add helper for lxw_doc_properties, add test doc_properties
2 parents d0b2fbd + 0d7f005 commit 0166fa2

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
matrix:
2525
version:
2626
- '1.10'
27-
- '1.6'
2827
- 'pre'
2928
os:
3029
- ubuntu-latest

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LibXLSXWriter"
22
uuid = "d9c5391f-cdb8-42e0-9032-91a2542ec5a4"
33
authors = ["Jaakko Ruohio [email protected]"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"

src/LibXLSXWriter.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ lxw_chart_line(; color=0x0, none=0x0, width=0.0, dash_type=0x0, transparency=0x0
1111
lxw_chart_pattern(; fg_color=0x0, bg_color=0x0, type=0x0) = lxw_chart_pattern(fg_color, bg_color, type)
1212
lxw_chart_point(; line=lxw_chart_line(), fill=lxw_chart_fill(), pattern=lxw_chart_pattern()) = lxw_chart_point(Ptr{line}(), Ptr{fill}(), Ptr{pattern}())
1313

14+
Cs(mystring) = Base.unsafe_convert(Cstring, mystring)
15+
lxw_doc_properties(; title="", subject="", author="", manager="", company="", category="", keywords="", comments="", status="", hyperlink_base="", created=0) =
16+
Ref(lxw_doc_properties(Cs(title), Cs(subject), Cs(author), Cs(manager), Cs(company), Cs(category), Cs(keywords), Cs(comments), Cs(status), Cs(hyperlink_base), created))
17+
1418
# utility.h
1519
CELL(cell) = lxw_name_to_row(cell), lxw_name_to_col(cell)
1620
COLS(cols) = lxw_name_to_col(cols), lxw_name_to_col_2(cols)

test/doc_properties.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# https://github.com/jmcnamara/libxlsxwriter/blob/main/examples/doc_properties.c
2+
3+
using LibXLSXWriter: workbook_new, workbook_add_worksheet, lxw_doc_properties, workbook_set_properties, worksheet_set_column, worksheet_write_string, workbook_close
4+
5+
workbook = workbook_new("doc_properties.xlsx")
6+
worksheet = workbook_add_worksheet(workbook, C_NULL)
7+
8+
# Create a properties structure and set some of the fields.
9+
properties = lxw_doc_properties(
10+
title = "This is an example spreadsheet",
11+
subject = "With document properties",
12+
author = "John McNamara",
13+
manager = "Dr. Heinz Doofenshmirtz",
14+
company = "of Wolves",
15+
category = "Example spreadsheets",
16+
keywords = "Sample, Example, Properties",
17+
comments = "Created with libxlsxwriter",
18+
status = "Quo",
19+
)
20+
21+
# Set the properties in the workbook.
22+
workbook_set_properties(workbook, properties)
23+
24+
# Add some text to the file.
25+
worksheet_set_column(worksheet, 0, 0, 50, C_NULL)
26+
worksheet_write_string(worksheet, 0, 0, "Select 'Workbook Properties' to see properties." , C_NULL)
27+
28+
workbook_close(workbook)

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ end
1616
@testset "demo" begin
1717
include("demo.jl")
1818
end
19+
@testset "doc_properties" begin
20+
include("doc_properties.jl")
21+
end
1922
@testset "format_num_format" begin
2023
include("format_num_format.jl")
2124
end

0 commit comments

Comments
 (0)