Struct edit_xlsx::WorkSheet

source ·
pub struct WorkSheet { /* private fields */ }

Implementations§

source§

impl WorkSheet

source

pub fn autofilter<L: LocationRange>(&mut self, loc_range: L)

Examples found in repository?
examples/autofilter.rs (line 38)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
fn main() -> WorkbookResult<()> {
    // Prepare autofilter data
    let text = fs::read_to_string("examples/autofilter_data.txt").unwrap();
    let mut text = text.split("\n");
    let headers: Vec<&str> = text.next().unwrap().split_whitespace().collect();
    let mut data: Vec<Vec<&str>> = vec![];
    for text in text { data.push(text.split_whitespace().collect()) }

    // Create a new workbook
    let mut workbook = Workbook::new();
    // Add some worksheets
    workbook.add_worksheet()?;
    workbook.add_worksheet()?;
    workbook.add_worksheet()?;
    workbook.add_worksheet()?;
    workbook.add_worksheet()?;
    workbook.add_worksheet()?;

    // Set up several sheets with the same data.
    for worksheet in workbook.worksheets() {
        // Make the columns wider.
        worksheet.set_column("A:D", 12.0)?;
        // // Make the header row larger.
        worksheet.set_row_with_format(1, 20.0, &Format::default().set_bold())?;
        // Make the headers bold.
        worksheet.write_row("A1", headers.iter())?;
    }

    //
    // Example 1. Autofilter without conditions.
    //

    let worksheet1 = workbook.get_worksheet(1)?;
    // Set the autofilter.
    worksheet1.autofilter("A1:D51");
    let mut row = 2;
    for row_data in &data {
        let mut col = 1;
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet1.write((row, col), num)?;
            } else {
                worksheet1.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }


    //
    // Example 2. Autofilter with a filter condition in the first column.
    //
    let worksheet2 = workbook.get_worksheet(2)?;
    // Set the autofilter.
    worksheet2.autofilter("A1:D51");
    // Add filter criteria.
    let mut filters = Filters::new();
    filters.and(Filter::eq("East"));
    worksheet2.filter_column("A", &filters);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data != Some(&"East") {
            // We need to hide rows that don't match the filter.
            worksheet2.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet2.write((row, col), num)?;
            } else {
                worksheet2.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }

    //
    // Example 3. Autofilter with a filter condition in the first column.
    //
    let worksheet3 = workbook.get_worksheet(3)?;
    // Set the autofilter.
    worksheet3.autofilter("A1:D51");
    // Add filter criteria.
    let mut filters = Filters::new();
    filters.and(Filter::eq("East")).or(Filter::eq("South"));
    worksheet3.filter_column("A", &filters);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data != Some(&"East") && data != Some(&"South") {
            // We need to hide rows that don't match the filter.
            worksheet3.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet3.write((row, col), num)?;
            } else {
                worksheet3.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }


    //
    // Example 4. Autofilter with filter conditions in two columns.
    //
    let worksheet4 = workbook.get_worksheet(4)?;
    // Set the autofilter.
    worksheet4.autofilter("A1:D51");
    // Add filter criteria.
    let mut filters_a = Filters::new();
    filters_a.and(Filter::eq("East"));
    worksheet4.filter_column("A", &filters_a);
    let mut filters_c = Filters::new();
    filters_c.and(Filter::gt("3000")).and(Filter::lt("8000"));
    worksheet4.filter_column("C", &filters_c);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data != Some(&"East") {
            // We need to hide rows that don't match the filter.
            worksheet4.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                if num <= 3000 || num >= 8000 {
                    worksheet4.hide_row(row)?;
                }
                worksheet4.write((row, col), num)?;
            } else {
                worksheet4.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }


    //
    // Example 5. Autofilter with a filter list condition in one of the columns.
    //
    let worksheet5 = workbook.get_worksheet(5)?;
    // Set the autofilter.
    worksheet5.autofilter("A1:D51");
    // Add filter criteria.
    let filters_list = Filters::eq(vec!["East", "North", "South"]);
    worksheet5.filter_column("A", &filters_list);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data != Some(&"East") && data != Some(&"North") && data != Some(&"South") {
            // We need to hide rows that don't match the filter.
            worksheet5.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet5.write((row, col), num)?;
            } else {
                worksheet5.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }

    //
    // Example 6. Autofilter with filter for blanks.
    //
    let worksheet6 = workbook.get_worksheet(6)?;
    // Set the autofilter.
    worksheet6.autofilter("A1:D51");
    // Add filter criteria.
    let filters = Filters::blank();
    worksheet6.filter_column("A", &filters);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    // Simulate a blank cell in the data.
    data[5][0] = "";

    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data != Some(&"") {
            // We need to hide rows that don't match the filter.
            worksheet6.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet6.write((row, col), num)?;
            } else {
                worksheet6.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }

    //
    // Example 7. Autofilter with filter for non-blanks.
    //
    let worksheet7 = workbook.get_worksheet(7)?;
    // Set the autofilter.
    worksheet7.autofilter("A1:D51");
    // Add filter criteria.
    let filters = Filters::not_blank();
    worksheet7.filter_column("A", &filters);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    // Simulate a blank cell in the data.

    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data == Some(&"") {
            // We need to hide rows that don't match the filter.
            worksheet7.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet7.write((row, col), num)?;
            } else {
                worksheet7.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }


    workbook.save_as("examples/autofilter.xlsx")?;

    Ok(())
}
source

pub fn filter_column<L: Location>(&mut self, col: L, filters: &Filters<'_>)

Examples found in repository?
examples/autofilter.rs (line 64)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
fn main() -> WorkbookResult<()> {
    // Prepare autofilter data
    let text = fs::read_to_string("examples/autofilter_data.txt").unwrap();
    let mut text = text.split("\n");
    let headers: Vec<&str> = text.next().unwrap().split_whitespace().collect();
    let mut data: Vec<Vec<&str>> = vec![];
    for text in text { data.push(text.split_whitespace().collect()) }

    // Create a new workbook
    let mut workbook = Workbook::new();
    // Add some worksheets
    workbook.add_worksheet()?;
    workbook.add_worksheet()?;
    workbook.add_worksheet()?;
    workbook.add_worksheet()?;
    workbook.add_worksheet()?;
    workbook.add_worksheet()?;

    // Set up several sheets with the same data.
    for worksheet in workbook.worksheets() {
        // Make the columns wider.
        worksheet.set_column("A:D", 12.0)?;
        // // Make the header row larger.
        worksheet.set_row_with_format(1, 20.0, &Format::default().set_bold())?;
        // Make the headers bold.
        worksheet.write_row("A1", headers.iter())?;
    }

    //
    // Example 1. Autofilter without conditions.
    //

    let worksheet1 = workbook.get_worksheet(1)?;
    // Set the autofilter.
    worksheet1.autofilter("A1:D51");
    let mut row = 2;
    for row_data in &data {
        let mut col = 1;
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet1.write((row, col), num)?;
            } else {
                worksheet1.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }


    //
    // Example 2. Autofilter with a filter condition in the first column.
    //
    let worksheet2 = workbook.get_worksheet(2)?;
    // Set the autofilter.
    worksheet2.autofilter("A1:D51");
    // Add filter criteria.
    let mut filters = Filters::new();
    filters.and(Filter::eq("East"));
    worksheet2.filter_column("A", &filters);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data != Some(&"East") {
            // We need to hide rows that don't match the filter.
            worksheet2.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet2.write((row, col), num)?;
            } else {
                worksheet2.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }

    //
    // Example 3. Autofilter with a filter condition in the first column.
    //
    let worksheet3 = workbook.get_worksheet(3)?;
    // Set the autofilter.
    worksheet3.autofilter("A1:D51");
    // Add filter criteria.
    let mut filters = Filters::new();
    filters.and(Filter::eq("East")).or(Filter::eq("South"));
    worksheet3.filter_column("A", &filters);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data != Some(&"East") && data != Some(&"South") {
            // We need to hide rows that don't match the filter.
            worksheet3.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet3.write((row, col), num)?;
            } else {
                worksheet3.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }


    //
    // Example 4. Autofilter with filter conditions in two columns.
    //
    let worksheet4 = workbook.get_worksheet(4)?;
    // Set the autofilter.
    worksheet4.autofilter("A1:D51");
    // Add filter criteria.
    let mut filters_a = Filters::new();
    filters_a.and(Filter::eq("East"));
    worksheet4.filter_column("A", &filters_a);
    let mut filters_c = Filters::new();
    filters_c.and(Filter::gt("3000")).and(Filter::lt("8000"));
    worksheet4.filter_column("C", &filters_c);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data != Some(&"East") {
            // We need to hide rows that don't match the filter.
            worksheet4.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                if num <= 3000 || num >= 8000 {
                    worksheet4.hide_row(row)?;
                }
                worksheet4.write((row, col), num)?;
            } else {
                worksheet4.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }


    //
    // Example 5. Autofilter with a filter list condition in one of the columns.
    //
    let worksheet5 = workbook.get_worksheet(5)?;
    // Set the autofilter.
    worksheet5.autofilter("A1:D51");
    // Add filter criteria.
    let filters_list = Filters::eq(vec!["East", "North", "South"]);
    worksheet5.filter_column("A", &filters_list);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data != Some(&"East") && data != Some(&"North") && data != Some(&"South") {
            // We need to hide rows that don't match the filter.
            worksheet5.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet5.write((row, col), num)?;
            } else {
                worksheet5.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }

    //
    // Example 6. Autofilter with filter for blanks.
    //
    let worksheet6 = workbook.get_worksheet(6)?;
    // Set the autofilter.
    worksheet6.autofilter("A1:D51");
    // Add filter criteria.
    let filters = Filters::blank();
    worksheet6.filter_column("A", &filters);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    // Simulate a blank cell in the data.
    data[5][0] = "";

    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data != Some(&"") {
            // We need to hide rows that don't match the filter.
            worksheet6.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet6.write((row, col), num)?;
            } else {
                worksheet6.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }

    //
    // Example 7. Autofilter with filter for non-blanks.
    //
    let worksheet7 = workbook.get_worksheet(7)?;
    // Set the autofilter.
    worksheet7.autofilter("A1:D51");
    // Add filter criteria.
    let filters = Filters::not_blank();
    worksheet7.filter_column("A", &filters);
    // Hide the rows that don't match the filter criteria.
    let mut row = 2;
    // Simulate a blank cell in the data.

    for row_data in &data {
        let mut col = 1;
        let data = row_data.get(0);
        // Check for rows that match the filter.
        if data == Some(&"") {
            // We need to hide rows that don't match the filter.
            worksheet7.hide_row(row)?;
        }
        for data in row_data {
            if let Ok(num) = data.parse::<i32>() {
                worksheet7.write((row, col), num)?;
            } else {
                worksheet7.write((row, col), *data)?;
            }
            col += 1;
        }
        // Move on to the next worksheet row.
        row += 1;
    }


    workbook.save_as("examples/autofilter.xlsx")?;

    Ok(())
}
source§

impl WorkSheet

source

pub fn max_column(&self) -> u32

source

pub fn max_row(&self) -> u32

source

pub fn get_name(&self) -> &str

source

pub fn activate(&mut self)

source

pub fn select(&mut self)

source

pub fn right_to_left(&mut self)

Examples found in repository?
examples/right_to_left.rs (line 25)
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
fn main() -> WorkbookResult<()> {
    // Add the cell formats.
    let format_left_to_right = Format::default()
        .set_reading_order(1);
    let format_right_to_left = Format::default()
        .set_reading_order(2);

    // Create a new workbook
    let mut workbook = Workbook::new();
    // Set up some worksheets and set tab colors
    let worksheet1 = workbook.get_worksheet(1)?;

    // Make the columns wider for clarity.
    worksheet1.set_column("A:A", 25.0)?;

    // Standard direction:         | A1 | B1 | C1 | ...
    worksheet1.write("A1", "نص عربي / English text")?;  // Default direction.
    worksheet1.write_with_format("A2", "نص عربي / English text", &format_left_to_right)?;
    worksheet1.write_with_format("A3", "نص عربي / English text", &format_right_to_left)?;

    let worksheet2 = workbook.add_worksheet()?;
    worksheet2.set_column("A:A", 25.0)?;
    worksheet2.right_to_left();

    // Right to left direction:    ... | C1 | B1 | A1 |
    worksheet2.write("A1", "نص عربي / English text")?;  // Default direction.
    worksheet2.write_with_format("A2", "نص عربي / English text", &format_left_to_right)?;
    worksheet2.write_with_format("A3", "نص عربي / English text", &format_right_to_left)?;

    workbook.save_as("examples/right_to_left.xlsx")?;

    Ok(())
}
source

pub fn set_top_left_cell<L: Location>(&mut self, loc: L)

source

pub fn set_zoom(&mut self, zoom_scale: u16)

source

pub fn set_selection<L: LocationRange>( &mut self, loc_range: L ) -> WorkSheetResult<()>

Examples found in repository?
examples/panes.rs (line 23)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
fn main() -> WorkbookResult<()> {
    let header_format = Format::default()
        .set_bold()
        .set_align(FormatAlignType::Center)
        .set_align(FormatAlignType::VerticalCenter)
        .set_border(FormatBorderType::Medium)
        .set_background_color(FormatColor::RGB("00D7E4BC"));
    let center_format = Format::default().set_align(FormatAlignType::Center);

    // Create a new workbook
    let mut workbook = Workbook::new();

    //
    // Example 1. Freeze pane on the top row.
    //
    let worksheet1 = workbook.add_worksheet_by_name("Panes 1")?;
    worksheet1.freeze_panes("A2")?;
    // Other sheet formatting.
    worksheet1.set_column("A:I", 16.0)?;
    worksheet1.set_row(0, 20.0)?;
    worksheet1.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for col in 1..=9 {
        worksheet1.write_with_format((1, col), "Scroll down", &header_format)?;
    }

    for row in 2..100 {
        for col in 1..=9 {
            worksheet1.write_with_format((row, col), row, &center_format)?;
        }
    }

    //
    // Example 2. Freeze pane on the left column.
    //
    let worksheet2 = workbook.add_worksheet_by_name("Panes 2")?;
    worksheet2.freeze_panes("B1")?;

    // Other sheet formatting.
    worksheet2.set_column("A:A", 16.0)?;
    worksheet2.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for row in 1..=50 {
        worksheet2.write_with_format((row, 1), "Scroll right", &header_format)?;
        for col in 2..=26 {
            worksheet2.write_with_format((row, col), col, &center_format)?;
        }
    }

    //
    // Example 3. Freeze pane on the top row and left column.
    //
    let worksheet3 = workbook.add_worksheet_by_name("Panes 3")?;
    worksheet3.freeze_panes((2, 2))?;

    // Other sheet formatting.
    worksheet3.set_column("A:Z", 16.0)?;
    worksheet3.set_row(1, 20.0)?;
    worksheet3.set_selection("C3:C3")?;
    worksheet3.write_with_format((1, 1), "", &header_format)?;

    // Some text to demonstrate scrolling.
    for col in 2..=26 {
        worksheet3.write_with_format((1, col), "Scroll down", &header_format)?;
    }

    for row in 2..=50 {
        worksheet3.write_with_format((row, 1), "Scroll right", &header_format)?;
        for col in 2..=26 {
            worksheet3.write_with_format((row, col), col, &center_format)?;
        }
    }

    //
    // Example 4. Split pane on the top row and left column.
    //
    // The divisions must be specified in terms of row and column dimensions.
    //
    let worksheet4 = workbook.add_worksheet_by_name("Panes 4")?;
    // Set the default row height is 17 and set the column width is 13
    worksheet4.set_column("A:Z", 13.0)?;
    worksheet4.set_default_row(17.0);
    worksheet4.split_panes(2.0 * 13.0, 2.0 * 17.0)?;
    worksheet4.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for col in 1..=26 {
        worksheet4.write_with_format((1, col), "Scroll", &center_format)?;
    }
    for row in 1..=50 {
        worksheet4.write_with_format((row, 1), "Scroll", &center_format)?;
        for col in 1..=26 {
            worksheet4.write_with_format((row, col), col, &center_format)?;
        }
    }

    workbook.save_as("examples/panes.xlsx")?;
    Ok(())
}
source

pub fn freeze_panes<L: Location>(&mut self, loc: L) -> WorkSheetResult<()>

Examples found in repository?
examples/panes.rs (line 19)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
fn main() -> WorkbookResult<()> {
    let header_format = Format::default()
        .set_bold()
        .set_align(FormatAlignType::Center)
        .set_align(FormatAlignType::VerticalCenter)
        .set_border(FormatBorderType::Medium)
        .set_background_color(FormatColor::RGB("00D7E4BC"));
    let center_format = Format::default().set_align(FormatAlignType::Center);

    // Create a new workbook
    let mut workbook = Workbook::new();

    //
    // Example 1. Freeze pane on the top row.
    //
    let worksheet1 = workbook.add_worksheet_by_name("Panes 1")?;
    worksheet1.freeze_panes("A2")?;
    // Other sheet formatting.
    worksheet1.set_column("A:I", 16.0)?;
    worksheet1.set_row(0, 20.0)?;
    worksheet1.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for col in 1..=9 {
        worksheet1.write_with_format((1, col), "Scroll down", &header_format)?;
    }

    for row in 2..100 {
        for col in 1..=9 {
            worksheet1.write_with_format((row, col), row, &center_format)?;
        }
    }

    //
    // Example 2. Freeze pane on the left column.
    //
    let worksheet2 = workbook.add_worksheet_by_name("Panes 2")?;
    worksheet2.freeze_panes("B1")?;

    // Other sheet formatting.
    worksheet2.set_column("A:A", 16.0)?;
    worksheet2.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for row in 1..=50 {
        worksheet2.write_with_format((row, 1), "Scroll right", &header_format)?;
        for col in 2..=26 {
            worksheet2.write_with_format((row, col), col, &center_format)?;
        }
    }

    //
    // Example 3. Freeze pane on the top row and left column.
    //
    let worksheet3 = workbook.add_worksheet_by_name("Panes 3")?;
    worksheet3.freeze_panes((2, 2))?;

    // Other sheet formatting.
    worksheet3.set_column("A:Z", 16.0)?;
    worksheet3.set_row(1, 20.0)?;
    worksheet3.set_selection("C3:C3")?;
    worksheet3.write_with_format((1, 1), "", &header_format)?;

    // Some text to demonstrate scrolling.
    for col in 2..=26 {
        worksheet3.write_with_format((1, col), "Scroll down", &header_format)?;
    }

    for row in 2..=50 {
        worksheet3.write_with_format((row, 1), "Scroll right", &header_format)?;
        for col in 2..=26 {
            worksheet3.write_with_format((row, col), col, &center_format)?;
        }
    }

    //
    // Example 4. Split pane on the top row and left column.
    //
    // The divisions must be specified in terms of row and column dimensions.
    //
    let worksheet4 = workbook.add_worksheet_by_name("Panes 4")?;
    // Set the default row height is 17 and set the column width is 13
    worksheet4.set_column("A:Z", 13.0)?;
    worksheet4.set_default_row(17.0);
    worksheet4.split_panes(2.0 * 13.0, 2.0 * 17.0)?;
    worksheet4.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for col in 1..=26 {
        worksheet4.write_with_format((1, col), "Scroll", &center_format)?;
    }
    for row in 1..=50 {
        worksheet4.write_with_format((row, 1), "Scroll", &center_format)?;
        for col in 1..=26 {
            worksheet4.write_with_format((row, col), col, &center_format)?;
        }
    }

    workbook.save_as("examples/panes.xlsx")?;
    Ok(())
}
source

pub fn split_panes(&mut self, width: f64, height: f64) -> WorkSheetResult<()>

Examples found in repository?
examples/panes.rs (line 87)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
fn main() -> WorkbookResult<()> {
    let header_format = Format::default()
        .set_bold()
        .set_align(FormatAlignType::Center)
        .set_align(FormatAlignType::VerticalCenter)
        .set_border(FormatBorderType::Medium)
        .set_background_color(FormatColor::RGB("00D7E4BC"));
    let center_format = Format::default().set_align(FormatAlignType::Center);

    // Create a new workbook
    let mut workbook = Workbook::new();

    //
    // Example 1. Freeze pane on the top row.
    //
    let worksheet1 = workbook.add_worksheet_by_name("Panes 1")?;
    worksheet1.freeze_panes("A2")?;
    // Other sheet formatting.
    worksheet1.set_column("A:I", 16.0)?;
    worksheet1.set_row(0, 20.0)?;
    worksheet1.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for col in 1..=9 {
        worksheet1.write_with_format((1, col), "Scroll down", &header_format)?;
    }

    for row in 2..100 {
        for col in 1..=9 {
            worksheet1.write_with_format((row, col), row, &center_format)?;
        }
    }

    //
    // Example 2. Freeze pane on the left column.
    //
    let worksheet2 = workbook.add_worksheet_by_name("Panes 2")?;
    worksheet2.freeze_panes("B1")?;

    // Other sheet formatting.
    worksheet2.set_column("A:A", 16.0)?;
    worksheet2.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for row in 1..=50 {
        worksheet2.write_with_format((row, 1), "Scroll right", &header_format)?;
        for col in 2..=26 {
            worksheet2.write_with_format((row, col), col, &center_format)?;
        }
    }

    //
    // Example 3. Freeze pane on the top row and left column.
    //
    let worksheet3 = workbook.add_worksheet_by_name("Panes 3")?;
    worksheet3.freeze_panes((2, 2))?;

    // Other sheet formatting.
    worksheet3.set_column("A:Z", 16.0)?;
    worksheet3.set_row(1, 20.0)?;
    worksheet3.set_selection("C3:C3")?;
    worksheet3.write_with_format((1, 1), "", &header_format)?;

    // Some text to demonstrate scrolling.
    for col in 2..=26 {
        worksheet3.write_with_format((1, col), "Scroll down", &header_format)?;
    }

    for row in 2..=50 {
        worksheet3.write_with_format((row, 1), "Scroll right", &header_format)?;
        for col in 2..=26 {
            worksheet3.write_with_format((row, col), col, &center_format)?;
        }
    }

    //
    // Example 4. Split pane on the top row and left column.
    //
    // The divisions must be specified in terms of row and column dimensions.
    //
    let worksheet4 = workbook.add_worksheet_by_name("Panes 4")?;
    // Set the default row height is 17 and set the column width is 13
    worksheet4.set_column("A:Z", 13.0)?;
    worksheet4.set_default_row(17.0);
    worksheet4.split_panes(2.0 * 13.0, 2.0 * 17.0)?;
    worksheet4.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for col in 1..=26 {
        worksheet4.write_with_format((1, col), "Scroll", &center_format)?;
    }
    for row in 1..=50 {
        worksheet4.write_with_format((row, 1), "Scroll", &center_format)?;
        for col in 1..=26 {
            worksheet4.write_with_format((row, col), col, &center_format)?;
        }
    }

    workbook.save_as("examples/panes.xlsx")?;
    Ok(())
}
source

pub fn set_default_row(&mut self, height: f64)

Examples found in repository?
examples/panes.rs (line 86)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
fn main() -> WorkbookResult<()> {
    let header_format = Format::default()
        .set_bold()
        .set_align(FormatAlignType::Center)
        .set_align(FormatAlignType::VerticalCenter)
        .set_border(FormatBorderType::Medium)
        .set_background_color(FormatColor::RGB("00D7E4BC"));
    let center_format = Format::default().set_align(FormatAlignType::Center);

    // Create a new workbook
    let mut workbook = Workbook::new();

    //
    // Example 1. Freeze pane on the top row.
    //
    let worksheet1 = workbook.add_worksheet_by_name("Panes 1")?;
    worksheet1.freeze_panes("A2")?;
    // Other sheet formatting.
    worksheet1.set_column("A:I", 16.0)?;
    worksheet1.set_row(0, 20.0)?;
    worksheet1.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for col in 1..=9 {
        worksheet1.write_with_format((1, col), "Scroll down", &header_format)?;
    }

    for row in 2..100 {
        for col in 1..=9 {
            worksheet1.write_with_format((row, col), row, &center_format)?;
        }
    }

    //
    // Example 2. Freeze pane on the left column.
    //
    let worksheet2 = workbook.add_worksheet_by_name("Panes 2")?;
    worksheet2.freeze_panes("B1")?;

    // Other sheet formatting.
    worksheet2.set_column("A:A", 16.0)?;
    worksheet2.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for row in 1..=50 {
        worksheet2.write_with_format((row, 1), "Scroll right", &header_format)?;
        for col in 2..=26 {
            worksheet2.write_with_format((row, col), col, &center_format)?;
        }
    }

    //
    // Example 3. Freeze pane on the top row and left column.
    //
    let worksheet3 = workbook.add_worksheet_by_name("Panes 3")?;
    worksheet3.freeze_panes((2, 2))?;

    // Other sheet formatting.
    worksheet3.set_column("A:Z", 16.0)?;
    worksheet3.set_row(1, 20.0)?;
    worksheet3.set_selection("C3:C3")?;
    worksheet3.write_with_format((1, 1), "", &header_format)?;

    // Some text to demonstrate scrolling.
    for col in 2..=26 {
        worksheet3.write_with_format((1, col), "Scroll down", &header_format)?;
    }

    for row in 2..=50 {
        worksheet3.write_with_format((row, 1), "Scroll right", &header_format)?;
        for col in 2..=26 {
            worksheet3.write_with_format((row, col), col, &center_format)?;
        }
    }

    //
    // Example 4. Split pane on the top row and left column.
    //
    // The divisions must be specified in terms of row and column dimensions.
    //
    let worksheet4 = workbook.add_worksheet_by_name("Panes 4")?;
    // Set the default row height is 17 and set the column width is 13
    worksheet4.set_column("A:Z", 13.0)?;
    worksheet4.set_default_row(17.0);
    worksheet4.split_panes(2.0 * 13.0, 2.0 * 17.0)?;
    worksheet4.set_selection("C3:C3")?;

    // Some text to demonstrate scrolling.
    for col in 1..=26 {
        worksheet4.write_with_format((1, col), "Scroll", &center_format)?;
    }
    for row in 1..=50 {
        worksheet4.write_with_format((row, 1), "Scroll", &center_format)?;
        for col in 1..=26 {
            worksheet4.write_with_format((row, col), col, &center_format)?;
        }
    }

    workbook.save_as("examples/panes.xlsx")?;
    Ok(())
}
source

pub fn hide_unused_rows(&mut self, hide: bool)

Examples found in repository?
examples/hide_row_col.rs (line 14)
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
fn main() -> WorkbookResult<()> {
    // Create a new workbook
    let mut workbook = Workbook::new();

    let worksheet = workbook.get_worksheet(1)?;

    // Write some data.
    worksheet.write("D1", "Some hidden columns.")?;
    worksheet.write("A8", "Some hidden rows.")?;

    // Hide all rows without data.
    worksheet.hide_unused_rows(true);

    // Set the height of empty rows that we do want to display even if it is
    // the default height.
    for row in 2..=7 {
        worksheet.set_row(row, 15.0)?;
    }

    // Columns can be hidden explicitly. This doesn't increase the file size..
    worksheet.hide_column("G:XFD")?;

    workbook.save_as("examples/hide_row_col.xlsx")?;
    Ok(())
}
source

pub fn outline_settings( &mut self, visible: bool, symbols_below: bool, symbols_right: bool, auto_style: bool )

source

pub fn ignore_errors<L: Location>(&mut self, error_map: HashMap<&str, L>)

Examples found in repository?
examples/ignore_errors.rs (line 20)
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
fn main() -> WorkbookResult<()> {
    let mut workbook = Workbook::new();
    let worksheet = workbook.get_worksheet(1)?;

    // Write strings that looks like numbers. This will cause an Excel warning.
    worksheet.write_string("C2", "123".to_string())?;
    worksheet.write_string("C3", "123".to_string())?;

    // Write a divide by zero formula. This will also cause an Excel warning.
    worksheet.write_formula("C5", "=1/0")?;
    worksheet.write_formula("C6", "=1/0")?;

    // Turn off some of the warnings:
    let mut error_map = HashMap::new();
    error_map.insert("number_stored_as_text", "C3");
    error_map.insert("eval_error", "C6");
    worksheet.ignore_errors(error_map);

    // Write some descriptions for the cells and make the column wider for clarity.
    worksheet.set_column("B:B", 16.0)?;
    worksheet.write("B2", "Warning:")?;
    worksheet.write("B3", "Warning turned off:")?;
    worksheet.write("B5", "Warning:")?;
    worksheet.write("B6", "Warning turned off:")?;

    workbook.save_as("examples/ignore_errors.xlsx")?;
    Ok(())
}
source

pub fn hide(&mut self)

Examples found in repository?
examples/hide_sheet.rs (line 15)
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
fn main() -> WorkbookResult<()> {
    // Create a new workbook
    let mut workbook = Workbook::new();
    let worksheet1 = workbook.get_worksheet(1)?;

    worksheet1.set_column("A:A", 30.0)?;
    worksheet1.write("A1", "Sheet2 is hidden")?;

    // Hide Sheet2. It won't be visible until it is unhidden in Excel.
    let worksheet2 = workbook.add_worksheet()?;
    worksheet2.set_column("A:A", 30.0)?;
    // worksheet2.activate();
    worksheet2.hide();
    worksheet2.write("A1", "Now it's my turn to find you!")?;
    // Note, you can't hide the "active" worksheet, which generally is the
    // first worksheet, since this would cause an Excel error. So, in order to hide
    // the first sheet you will need to activate another worksheet:
    //
    //    worksheet2.activate();
    //    worksheet1.hide();

    let worksheet3 = workbook.add_worksheet()?;
    worksheet3.set_column("A:A", 30.0)?;
    worksheet3.write("A1", "Sheet2 is hidden")?;

    workbook.save_as("examples/hide_sheet.xlsx")?;
    Ok(())
}
source

pub fn set_tab_color(&mut self, tab_color: &FormatColor<'_>)

Examples found in repository?
examples/tab_color.rs (line 8)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() -> WorkbookResult<()> {
    // Create a new workbook
    let mut workbook = Workbook::new();
    // Set up some worksheets and set tab colors
    let worksheet1 = workbook.get_worksheet(1)?;
    worksheet1.set_tab_color(&FormatColor::RGB("00ff0000")); // Red
    let worksheet2 = workbook.add_worksheet()?;
    worksheet2.set_tab_color(&FormatColor::RGB("0000ff00")); // Green
    let worksheet3 = workbook.add_worksheet()?;
    worksheet3.set_tab_color(&FormatColor::RGB("00FF9900")); // Orange
    let worksheet4 = workbook.add_worksheet()?;
    // worksheet4 will have the default color.
    workbook.save_as("examples/tab_color.xlsx")?;
    Ok(())
}
More examples
Hide additional examples
examples/hello_world.rs (line 33)
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
fn main() -> WorkbookResult<()> {
    // Create a new workbook
    let mut workbook = Workbook::new();
    let worksheet = workbook.get_worksheet(1)?;
    // write some text
    WorkSheet::write(worksheet, "A1", "Hello")?;
    worksheet.write("B1", "World")?;
    worksheet.write("C1", "Rust")?;
    // Adjust font size
    let big = Format::default().set_size(32);
    worksheet.write_with_format("B1", "big text", &big)?;
    // Change font color
    let red = Format::default().set_color(FormatColor::RGB("00FF7777"));
    worksheet.write_with_format("C1", "red text", &red)?;
    // Change the font style
    let bold = red.set_bold();
    worksheet.write_with_format("D1", "red bold text", &bold)?;
    // adjust the text align
    let left_top = Format::default().set_align(FormatAlignType::Left).set_align(FormatAlignType::Top);
    worksheet.write_with_format("A2", "left top", &left_top)?;
    // add borders
    let thin_border = Format::default().set_border(FormatBorderType::Thin);
    worksheet.write_with_format("B2", "bordered text", &thin_border)?;
    // add background
    let red_background = Format::default().set_background_color(FormatColor::RGB("00FF7777"));
    worksheet.write_with_format("C2", "red", &red_background)?;
    // add a number
    worksheet.write("D2", std::f64::consts::PI)?;
    // add a new worksheet and set a tab color
    let worksheet = workbook.add_worksheet_by_name("Other examples")?;
    worksheet.set_tab_color(&FormatColor::RGB("00FF9900")); // Orange
    // Set a background.
    worksheet.set_background("examples/pics/ferris.png")?;
    // Create a format to use in the merged range.
    let merge_format = Format::default()
        .set_bold()
        .set_border(FormatBorderType::Double)
        .set_align(FormatAlignType::Center)
        .set_align(FormatAlignType::VerticalCenter)
        .set_background_color(FormatColor::RGB("00ffff00"));
    // Merge cells.
    worksheet.merge_range_with_format("A1:C3", "Merged Range", &merge_format)?;
    // Add an image
    worksheet.insert_image("A4:C10", &"./examples/pics/rust.png");
    workbook.save_as("examples/hello_world.xlsx")?;
    Ok(())
}
source

pub fn set_background<P: AsRef<Path>>( &mut self, filename: P ) -> WorkSheetResult<()>

Examples found in repository?
examples/background.rs (line 9)
3
4
5
6
7
8
9
10
11
12
13
fn main() -> WorkbookResult<()> {
    // Create a new workbook
    let mut workbook = Workbook::new();
    // Use the default worksheet
    let worksheet = workbook.get_worksheet(1)?;
    // Set the background image.
    worksheet.set_background("examples/pics/ferris.png")?;

    workbook.save_as("examples/background.xlsx")?;
    Ok(())
}
More examples
Hide additional examples
examples/hello_world.rs (line 35)
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
fn main() -> WorkbookResult<()> {
    // Create a new workbook
    let mut workbook = Workbook::new();
    let worksheet = workbook.get_worksheet(1)?;
    // write some text
    WorkSheet::write(worksheet, "A1", "Hello")?;
    worksheet.write("B1", "World")?;
    worksheet.write("C1", "Rust")?;
    // Adjust font size
    let big = Format::default().set_size(32);
    worksheet.write_with_format("B1", "big text", &big)?;
    // Change font color
    let red = Format::default().set_color(FormatColor::RGB("00FF7777"));
    worksheet.write_with_format("C1", "red text", &red)?;
    // Change the font style
    let bold = red.set_bold();
    worksheet.write_with_format("D1", "red bold text", &bold)?;
    // adjust the text align
    let left_top = Format::default().set_align(FormatAlignType::Left).set_align(FormatAlignType::Top);
    worksheet.write_with_format("A2", "left top", &left_top)?;
    // add borders
    let thin_border = Format::default().set_border(FormatBorderType::Thin);
    worksheet.write_with_format("B2", "bordered text", &thin_border)?;
    // add background
    let red_background = Format::default().set_background_color(FormatColor::RGB("00FF7777"));
    worksheet.write_with_format("C2", "red", &red_background)?;
    // add a number
    worksheet.write("D2", std::f64::consts::PI)?;
    // add a new worksheet and set a tab color
    let worksheet = workbook.add_worksheet_by_name("Other examples")?;
    worksheet.set_tab_color(&FormatColor::RGB("00FF9900")); // Orange
    // Set a background.
    worksheet.set_background("examples/pics/ferris.png")?;
    // Create a format to use in the merged range.
    let merge_format = Format::default()
        .set_bold()
        .set_border(FormatBorderType::Double)
        .set_align(FormatAlignType::Center)
        .set_align(FormatAlignType::VerticalCenter)
        .set_background_color(FormatColor::RGB("00ffff00"));
    // Merge cells.
    worksheet.merge_range_with_format("A1:C3", "Merged Range", &merge_format)?;
    // Add an image
    worksheet.insert_image("A4:C10", &"./examples/pics/rust.png");
    workbook.save_as("examples/hello_world.xlsx")?;
    Ok(())
}
source

pub fn insert_image<L: LocationRange, P: AsRef<Path>>( &mut self, loc_range: L, filename: &P )

Examples found in repository?
examples/image.rs (line 6)
3
4
5
6
7
8
9
fn main() -> WorkbookResult<()> {
    let mut workbook = Workbook::new();
    let worksheet = workbook.get_worksheet(1)?;
    worksheet.insert_image("A1:D4", &"./examples/pics/ferris.png");
    workbook.save_as("examples/image.xlsx")?;
    Ok(())
}
More examples
Hide additional examples
examples/hello_world.rs (line 46)
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
fn main() -> WorkbookResult<()> {
    // Create a new workbook
    let mut workbook = Workbook::new();
    let worksheet = workbook.get_worksheet(1)?;
    // write some text
    WorkSheet::write(worksheet, "A1", "Hello")?;
    worksheet.write("B1", "World")?;
    worksheet.write("C1", "Rust")?;
    // Adjust font size
    let big = Format::default().set_size(32);
    worksheet.write_with_format("B1", "big text", &big)?;
    // Change font color
    let red = Format::default().set_color(FormatColor::RGB("00FF7777"));
    worksheet.write_with_format("C1", "red text", &red)?;
    // Change the font style
    let bold = red.set_bold();
    worksheet.write_with_format("D1", "red bold text", &bold)?;
    // adjust the text align
    let left_top = Format::default().set_align(FormatAlignType::Left).set_align(FormatAlignType::Top);
    worksheet.write_with_format("A2", "left top", &left_top)?;
    // add borders
    let thin_border = Format::default().set_border(FormatBorderType::Thin);
    worksheet.write_with_format("B2", "bordered text", &thin_border)?;
    // add background
    let red_background = Format::default().set_background_color(FormatColor::RGB("00FF7777"));
    worksheet.write_with_format("C2", "red", &red_background)?;
    // add a number
    worksheet.write("D2", std::f64::consts::PI)?;
    // add a new worksheet and set a tab color
    let worksheet = workbook.add_worksheet_by_name("Other examples")?;
    worksheet.set_tab_color(&FormatColor::RGB("00FF9900")); // Orange
    // Set a background.
    worksheet.set_background("examples/pics/ferris.png")?;
    // Create a format to use in the merged range.
    let merge_format = Format::default()
        .set_bold()
        .set_border(FormatBorderType::Double)
        .set_align(FormatAlignType::Center)
        .set_align(FormatAlignType::VerticalCenter)
        .set_background_color(FormatColor::RGB("00ffff00"));
    // Merge cells.
    worksheet.merge_range_with_format("A1:C3", "Merged Range", &merge_format)?;
    // Add an image
    worksheet.insert_image("A4:C10", &"./examples/pics/rust.png");
    workbook.save_as("examples/hello_world.xlsx")?;
    Ok(())
}
source

pub fn id(&self) -> u32

Trait Implementations§

source§

impl Col for WorkSheet

source§

fn set_column<R: LocationRange>( &mut self, col_range: R, width: f64 ) -> WorkSheetResult<()>

source§

fn set_column_pixels<R: LocationRange>( &mut self, col_range: R, width: f64 ) -> WorkSheetResult<()>

source§

fn set_column_with_format<R: LocationRange>( &mut self, col_range: R, width: f64, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn set_column_pixels_with_format<R: LocationRange>( &mut self, col_range: R, width: f64, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn hide_column<R: LocationRange>(&mut self, col_range: R) -> WorkSheetResult<()>

source§

fn set_column_level<R: LocationRange>( &mut self, col_range: R, level: u32 ) -> WorkSheetResult<()>

source§

fn collapse_col<R: LocationRange>( &mut self, col_range: R ) -> WorkSheetResult<()>

source§

impl Debug for WorkSheet

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Row for WorkSheet

source§

fn set_row(&mut self, row: u32, height: f64) -> WorkSheetResult<()>

source§

fn set_row_pixels(&mut self, row: u32, height: f64) -> WorkSheetResult<()>

source§

fn set_row_with_format( &mut self, row: u32, height: f64, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn set_row_pixels_with_format( &mut self, row: u32, height: f64, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn hide_row(&mut self, row: u32) -> WorkSheetResult<()>

source§

fn set_row_level(&mut self, row: u32, level: u32) -> WorkSheetResult<()>

source§

fn collapse_row(&mut self, row: u32) -> WorkSheetResult<()>

source§

impl Write for WorkSheet

source§

fn write<L: Location, T: CellDisplay + CellValue>( &mut self, loc: L, data: T ) -> WorkSheetResult<()>

source§

fn write_string<L: Location>( &mut self, loc: L, data: String ) -> WorkSheetResult<()>

source§

fn write_number<L: Location>( &mut self, loc: L, data: i32 ) -> WorkSheetResult<()>

source§

fn write_double<L: Location>( &mut self, loc: L, data: f64 ) -> WorkSheetResult<()>

source§

fn write_boolean<L: Location>( &mut self, loc: L, data: bool ) -> WorkSheetResult<()>

source§

fn write_row<L: Location, T: CellDisplay + CellValue>( &mut self, loc: L, data: Iter<'_, T> ) -> WorkSheetResult<()>

source§

fn write_column<L: Location, T: CellDisplay + CellValue>( &mut self, loc: L, data: Iter<'_, T> ) -> WorkSheetResult<()>

source§

fn write_url<L: Location>(&mut self, loc: L, url: &str) -> WorkSheetResult<()>

source§

fn write_url_text<L: Location>( &mut self, loc: L, url: &str, data: &str ) -> WorkSheetResult<()>

source§

fn merge_range<L: LocationRange, T: CellDisplay + CellValue>( &mut self, loc: L, data: T ) -> WorkSheetResult<()>

source§

fn write_formula<L: Location>( &mut self, loc: L, data: &str ) -> WorkSheetResult<()>

source§

fn write_array_formula<L: Location>( &mut self, loc: L, data: &str ) -> WorkSheetResult<()>

source§

fn write_dynamic_array_formula<L: Location>( &mut self, loc: L, data: &str ) -> WorkSheetResult<()>

source§

fn write_with_format<L: Location, T: CellDisplay + CellValue>( &mut self, loc: L, data: T, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_string_with_format<L: Location>( &mut self, loc: L, data: String, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_number_with_format<L: Location>( &mut self, loc: L, data: i32, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_double_with_format<L: Location>( &mut self, loc: L, data: f64, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_boolean_with_format<L: Location>( &mut self, loc: L, data: bool, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_row_with_format<L: Location, T: CellDisplay + CellValue>( &mut self, loc: L, data: Iter<'_, T>, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_column_with_format<L: Location, T: CellDisplay + CellValue>( &mut self, loc: L, data: Iter<'_, T>, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_url_with_format<L: Location>( &mut self, loc: L, url: &str, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_url_data_with_format<L: Location>( &mut self, loc: L, url: &str, data: &str, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_formula_with_format<L: Location>( &mut self, loc: L, data: &str, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_array_formula_with_format<L: Location>( &mut self, loc: L, data: &str, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn write_dynamic_array_formula_with_format<L: LocationRange>( &mut self, loc_range: L, data: &str, format: &Format<'_> ) -> WorkSheetResult<()>

source§

fn merge_range_with_format<L: LocationRange, T: CellDisplay + CellValue>( &mut self, loc: L, data: T, format: &Format<'_> ) -> WorkSheetResult<()>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.