doc_properties/
doc_properties.rs

1//! A simple program to write some data to an Excel file.
2
3use karo::{col_range, index, Workbook};
4
5fn main() -> karo::Result<()> {
6    // Create a new workbook.
7    let mut workbook = Workbook::new();
8
9    // This method returns an &mut DocProperties.
10    let p = workbook.properties();
11    p.title = "This is an example spreadsheet".to_string();
12    p.subject = "With document properties".to_string();
13    p.author = "Max Mustermann".to_string();
14    p.manager = "Dr. Heinz Doofenshmirtz".to_string();
15    p.company = "of Wolves".to_string();
16    p.category = "Example spreadsheets".to_string();
17    p.keywords = "Sample, Example, Properties".to_string();
18    p.comments = "Created with karo".to_string();
19    p.status = "Quo".to_string();
20
21    {
22        // Add a worksheet with a user defined name.
23        let worksheet = workbook.add_worksheet(None)?;
24
25        // Widen the first column to make the text clearer.
26        worksheet.set_column(col_range(0, 0)?, 50f64, None)?;
27
28        worksheet.write_string(
29            index(0, 0)?,
30            "Select 'Workbook Properties' to see properties.",
31            None,
32        )?;
33    }
34
35    workbook.write_file("doc_properties.xlsx")?;
36
37    Ok(())
38}