Struct Filter

Source
pub struct Filter<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Filter<'a>

Source

pub fn eq(val: &'a str) -> Self

Examples found in repository?
examples/autofilter.rs (line 63)
4fn main() -> WorkbookResult<()> {
5    // Prepare autofilter data
6    let text = fs::read_to_string("examples/autofilter_data.txt").unwrap();
7    let mut text = text.split("\n");
8    let headers: Vec<&str> = text.next().unwrap().split_whitespace().collect();
9    let mut data: Vec<Vec<&str>> = vec![];
10    for text in text { data.push(text.split_whitespace().collect()) }
11
12    // Create a new workbook
13    let mut workbook = Workbook::new();
14    // Add some worksheets
15    workbook.add_worksheet()?;
16    workbook.add_worksheet()?;
17    workbook.add_worksheet()?;
18    workbook.add_worksheet()?;
19    workbook.add_worksheet()?;
20    workbook.add_worksheet()?;
21
22    // Set up several sheets with the same data.
23    for worksheet in workbook.worksheets_mut() {
24        // Make the columns wider.
25        worksheet.set_columns_width("A:D", 12.0)?;
26        // // Make the header row larger.
27        worksheet.set_row_height_with_format(1, 20.0, &Format::default().set_bold())?;
28        // Make the headers bold.
29        worksheet.write_row("A1", &headers)?;
30    }
31
32    //
33    // Example 1. Autofilter without conditions.
34    //
35
36    let worksheet1 = workbook.get_worksheet_mut(1)?;
37    // Set the autofilter.
38    worksheet1.autofilter("A1:D51");
39    let mut row = 2;
40    for row_data in &data {
41        let mut col = 1;
42        for data in row_data {
43            if let Ok(num) = data.parse::<i32>() {
44                worksheet1.write((row, col), num)?;
45            } else {
46                worksheet1.write((row, col), *data)?;
47            }
48            col += 1;
49        }
50        // Move on to the next worksheet row.
51        row += 1;
52    }
53
54
55    //
56    // Example 2. Autofilter with a filter condition in the first column.
57    //
58    let worksheet2 = workbook.get_worksheet_mut(2)?;
59    // Set the autofilter.
60    worksheet2.autofilter("A1:D51");
61    // Add filter criteria.
62    let mut filters = Filters::new();
63    filters.and(Filter::eq("East"));
64    worksheet2.filter_column("A", &filters);
65    // Hide the rows that don't match the filter criteria.
66    let mut row = 2;
67    for row_data in &data {
68        let mut col = 1;
69        let data = row_data.get(0);
70        // Check for rows that match the filter.
71        if data != Some(&"East") {
72            // We need to hide rows that don't match the filter.
73            worksheet2.hide_row(row)?;
74        }
75        for data in row_data {
76            if let Ok(num) = data.parse::<i32>() {
77                worksheet2.write((row, col), num)?;
78            } else {
79                worksheet2.write((row, col), *data)?;
80            }
81            col += 1;
82        }
83        // Move on to the next worksheet row.
84        row += 1;
85    }
86
87    //
88    // Example 3. Autofilter with a filter condition in the first column.
89    //
90    let worksheet3 = workbook.get_worksheet_mut(3)?;
91    // Set the autofilter.
92    worksheet3.autofilter("A1:D51");
93    // Add filter criteria.
94    let mut filters = Filters::new();
95    filters.and(Filter::eq("East")).or(Filter::eq("South"));
96    worksheet3.filter_column("A", &filters);
97    // Hide the rows that don't match the filter criteria.
98    let mut row = 2;
99    for row_data in &data {
100        let mut col = 1;
101        let data = row_data.get(0);
102        // Check for rows that match the filter.
103        if data != Some(&"East") && data != Some(&"South") {
104            // We need to hide rows that don't match the filter.
105            worksheet3.hide_row(row)?;
106        }
107        for data in row_data {
108            if let Ok(num) = data.parse::<i32>() {
109                worksheet3.write((row, col), num)?;
110            } else {
111                worksheet3.write((row, col), *data)?;
112            }
113            col += 1;
114        }
115        // Move on to the next worksheet row.
116        row += 1;
117    }
118
119
120    //
121    // Example 4. Autofilter with filter conditions in two columns.
122    //
123    let worksheet4 = workbook.get_worksheet_mut(4)?;
124    // Set the autofilter.
125    worksheet4.autofilter("A1:D51");
126    // Add filter criteria.
127    let mut filters_a = Filters::new();
128    filters_a.and(Filter::eq("East"));
129    worksheet4.filter_column("A", &filters_a);
130    let mut filters_c = Filters::new();
131    filters_c.and(Filter::gt("3000")).and(Filter::lt("8000"));
132    worksheet4.filter_column("C", &filters_c);
133    // Hide the rows that don't match the filter criteria.
134    let mut row = 2;
135    for row_data in &data {
136        let mut col = 1;
137        let data = row_data.get(0);
138        // Check for rows that match the filter.
139        if data != Some(&"East") {
140            // We need to hide rows that don't match the filter.
141            worksheet4.hide_row(row)?;
142        }
143        for data in row_data {
144            if let Ok(num) = data.parse::<i32>() {
145                if num <= 3000 || num >= 8000 {
146                    worksheet4.hide_row(row)?;
147                }
148                worksheet4.write((row, col), num)?;
149            } else {
150                worksheet4.write((row, col), *data)?;
151            }
152            col += 1;
153        }
154        // Move on to the next worksheet row.
155        row += 1;
156    }
157
158
159    //
160    // Example 5. Autofilter with a filter list condition in one of the columns.
161    //
162    let worksheet5 = workbook.get_worksheet_mut(5)?;
163    // Set the autofilter.
164    worksheet5.autofilter("A1:D51");
165    // Add filter criteria.
166    let filters_list = Filters::eq(vec!["East", "North", "South"]);
167    worksheet5.filter_column("A", &filters_list);
168    // Hide the rows that don't match the filter criteria.
169    let mut row = 2;
170    for row_data in &data {
171        let mut col = 1;
172        let data = row_data.get(0);
173        // Check for rows that match the filter.
174        if data != Some(&"East") && data != Some(&"North") && data != Some(&"South") {
175            // We need to hide rows that don't match the filter.
176            worksheet5.hide_row(row)?;
177        }
178        for data in row_data {
179            if let Ok(num) = data.parse::<i32>() {
180                worksheet5.write((row, col), num)?;
181            } else {
182                worksheet5.write((row, col), *data)?;
183            }
184            col += 1;
185        }
186        // Move on to the next worksheet row.
187        row += 1;
188    }
189
190    //
191    // Example 6. Autofilter with filter for blanks.
192    //
193    let worksheet6 = workbook.get_worksheet_mut(6)?;
194    // Set the autofilter.
195    worksheet6.autofilter("A1:D51");
196    // Add filter criteria.
197    let filters = Filters::blank();
198    worksheet6.filter_column("A", &filters);
199    // Hide the rows that don't match the filter criteria.
200    let mut row = 2;
201    // Simulate a blank cell in the data.
202    data[5][0] = "";
203
204    for row_data in &data {
205        let mut col = 1;
206        let data = row_data.get(0);
207        // Check for rows that match the filter.
208        if data != Some(&"") {
209            // We need to hide rows that don't match the filter.
210            worksheet6.hide_row(row)?;
211        }
212        for data in row_data {
213            if let Ok(num) = data.parse::<i32>() {
214                worksheet6.write((row, col), num)?;
215            } else {
216                worksheet6.write((row, col), *data)?;
217            }
218            col += 1;
219        }
220        // Move on to the next worksheet row.
221        row += 1;
222    }
223
224    //
225    // Example 7. Autofilter with filter for non-blanks.
226    //
227    let worksheet7 = workbook.get_worksheet_mut(7)?;
228    // Set the autofilter.
229    worksheet7.autofilter("A1:D51");
230    // Add filter criteria.
231    let filters = Filters::not_blank();
232    worksheet7.filter_column("A", &filters);
233    // Hide the rows that don't match the filter criteria.
234    let mut row = 2;
235    // Simulate a blank cell in the data.
236
237    for row_data in &data {
238        let mut col = 1;
239        let data = row_data.get(0);
240        // Check for rows that match the filter.
241        if data == Some(&"") {
242            // We need to hide rows that don't match the filter.
243            worksheet7.hide_row(row)?;
244        }
245        for data in row_data {
246            if let Ok(num) = data.parse::<i32>() {
247                worksheet7.write((row, col), num)?;
248            } else {
249                worksheet7.write((row, col), *data)?;
250            }
251            col += 1;
252        }
253        // Move on to the next worksheet row.
254        row += 1;
255    }
256
257
258    workbook.save_as("examples/autofilter.xlsx")?;
259
260    Ok(())
261}
Source

pub fn gt(val: &'a str) -> Self

Examples found in repository?
examples/autofilter.rs (line 131)
4fn main() -> WorkbookResult<()> {
5    // Prepare autofilter data
6    let text = fs::read_to_string("examples/autofilter_data.txt").unwrap();
7    let mut text = text.split("\n");
8    let headers: Vec<&str> = text.next().unwrap().split_whitespace().collect();
9    let mut data: Vec<Vec<&str>> = vec![];
10    for text in text { data.push(text.split_whitespace().collect()) }
11
12    // Create a new workbook
13    let mut workbook = Workbook::new();
14    // Add some worksheets
15    workbook.add_worksheet()?;
16    workbook.add_worksheet()?;
17    workbook.add_worksheet()?;
18    workbook.add_worksheet()?;
19    workbook.add_worksheet()?;
20    workbook.add_worksheet()?;
21
22    // Set up several sheets with the same data.
23    for worksheet in workbook.worksheets_mut() {
24        // Make the columns wider.
25        worksheet.set_columns_width("A:D", 12.0)?;
26        // // Make the header row larger.
27        worksheet.set_row_height_with_format(1, 20.0, &Format::default().set_bold())?;
28        // Make the headers bold.
29        worksheet.write_row("A1", &headers)?;
30    }
31
32    //
33    // Example 1. Autofilter without conditions.
34    //
35
36    let worksheet1 = workbook.get_worksheet_mut(1)?;
37    // Set the autofilter.
38    worksheet1.autofilter("A1:D51");
39    let mut row = 2;
40    for row_data in &data {
41        let mut col = 1;
42        for data in row_data {
43            if let Ok(num) = data.parse::<i32>() {
44                worksheet1.write((row, col), num)?;
45            } else {
46                worksheet1.write((row, col), *data)?;
47            }
48            col += 1;
49        }
50        // Move on to the next worksheet row.
51        row += 1;
52    }
53
54
55    //
56    // Example 2. Autofilter with a filter condition in the first column.
57    //
58    let worksheet2 = workbook.get_worksheet_mut(2)?;
59    // Set the autofilter.
60    worksheet2.autofilter("A1:D51");
61    // Add filter criteria.
62    let mut filters = Filters::new();
63    filters.and(Filter::eq("East"));
64    worksheet2.filter_column("A", &filters);
65    // Hide the rows that don't match the filter criteria.
66    let mut row = 2;
67    for row_data in &data {
68        let mut col = 1;
69        let data = row_data.get(0);
70        // Check for rows that match the filter.
71        if data != Some(&"East") {
72            // We need to hide rows that don't match the filter.
73            worksheet2.hide_row(row)?;
74        }
75        for data in row_data {
76            if let Ok(num) = data.parse::<i32>() {
77                worksheet2.write((row, col), num)?;
78            } else {
79                worksheet2.write((row, col), *data)?;
80            }
81            col += 1;
82        }
83        // Move on to the next worksheet row.
84        row += 1;
85    }
86
87    //
88    // Example 3. Autofilter with a filter condition in the first column.
89    //
90    let worksheet3 = workbook.get_worksheet_mut(3)?;
91    // Set the autofilter.
92    worksheet3.autofilter("A1:D51");
93    // Add filter criteria.
94    let mut filters = Filters::new();
95    filters.and(Filter::eq("East")).or(Filter::eq("South"));
96    worksheet3.filter_column("A", &filters);
97    // Hide the rows that don't match the filter criteria.
98    let mut row = 2;
99    for row_data in &data {
100        let mut col = 1;
101        let data = row_data.get(0);
102        // Check for rows that match the filter.
103        if data != Some(&"East") && data != Some(&"South") {
104            // We need to hide rows that don't match the filter.
105            worksheet3.hide_row(row)?;
106        }
107        for data in row_data {
108            if let Ok(num) = data.parse::<i32>() {
109                worksheet3.write((row, col), num)?;
110            } else {
111                worksheet3.write((row, col), *data)?;
112            }
113            col += 1;
114        }
115        // Move on to the next worksheet row.
116        row += 1;
117    }
118
119
120    //
121    // Example 4. Autofilter with filter conditions in two columns.
122    //
123    let worksheet4 = workbook.get_worksheet_mut(4)?;
124    // Set the autofilter.
125    worksheet4.autofilter("A1:D51");
126    // Add filter criteria.
127    let mut filters_a = Filters::new();
128    filters_a.and(Filter::eq("East"));
129    worksheet4.filter_column("A", &filters_a);
130    let mut filters_c = Filters::new();
131    filters_c.and(Filter::gt("3000")).and(Filter::lt("8000"));
132    worksheet4.filter_column("C", &filters_c);
133    // Hide the rows that don't match the filter criteria.
134    let mut row = 2;
135    for row_data in &data {
136        let mut col = 1;
137        let data = row_data.get(0);
138        // Check for rows that match the filter.
139        if data != Some(&"East") {
140            // We need to hide rows that don't match the filter.
141            worksheet4.hide_row(row)?;
142        }
143        for data in row_data {
144            if let Ok(num) = data.parse::<i32>() {
145                if num <= 3000 || num >= 8000 {
146                    worksheet4.hide_row(row)?;
147                }
148                worksheet4.write((row, col), num)?;
149            } else {
150                worksheet4.write((row, col), *data)?;
151            }
152            col += 1;
153        }
154        // Move on to the next worksheet row.
155        row += 1;
156    }
157
158
159    //
160    // Example 5. Autofilter with a filter list condition in one of the columns.
161    //
162    let worksheet5 = workbook.get_worksheet_mut(5)?;
163    // Set the autofilter.
164    worksheet5.autofilter("A1:D51");
165    // Add filter criteria.
166    let filters_list = Filters::eq(vec!["East", "North", "South"]);
167    worksheet5.filter_column("A", &filters_list);
168    // Hide the rows that don't match the filter criteria.
169    let mut row = 2;
170    for row_data in &data {
171        let mut col = 1;
172        let data = row_data.get(0);
173        // Check for rows that match the filter.
174        if data != Some(&"East") && data != Some(&"North") && data != Some(&"South") {
175            // We need to hide rows that don't match the filter.
176            worksheet5.hide_row(row)?;
177        }
178        for data in row_data {
179            if let Ok(num) = data.parse::<i32>() {
180                worksheet5.write((row, col), num)?;
181            } else {
182                worksheet5.write((row, col), *data)?;
183            }
184            col += 1;
185        }
186        // Move on to the next worksheet row.
187        row += 1;
188    }
189
190    //
191    // Example 6. Autofilter with filter for blanks.
192    //
193    let worksheet6 = workbook.get_worksheet_mut(6)?;
194    // Set the autofilter.
195    worksheet6.autofilter("A1:D51");
196    // Add filter criteria.
197    let filters = Filters::blank();
198    worksheet6.filter_column("A", &filters);
199    // Hide the rows that don't match the filter criteria.
200    let mut row = 2;
201    // Simulate a blank cell in the data.
202    data[5][0] = "";
203
204    for row_data in &data {
205        let mut col = 1;
206        let data = row_data.get(0);
207        // Check for rows that match the filter.
208        if data != Some(&"") {
209            // We need to hide rows that don't match the filter.
210            worksheet6.hide_row(row)?;
211        }
212        for data in row_data {
213            if let Ok(num) = data.parse::<i32>() {
214                worksheet6.write((row, col), num)?;
215            } else {
216                worksheet6.write((row, col), *data)?;
217            }
218            col += 1;
219        }
220        // Move on to the next worksheet row.
221        row += 1;
222    }
223
224    //
225    // Example 7. Autofilter with filter for non-blanks.
226    //
227    let worksheet7 = workbook.get_worksheet_mut(7)?;
228    // Set the autofilter.
229    worksheet7.autofilter("A1:D51");
230    // Add filter criteria.
231    let filters = Filters::not_blank();
232    worksheet7.filter_column("A", &filters);
233    // Hide the rows that don't match the filter criteria.
234    let mut row = 2;
235    // Simulate a blank cell in the data.
236
237    for row_data in &data {
238        let mut col = 1;
239        let data = row_data.get(0);
240        // Check for rows that match the filter.
241        if data == Some(&"") {
242            // We need to hide rows that don't match the filter.
243            worksheet7.hide_row(row)?;
244        }
245        for data in row_data {
246            if let Ok(num) = data.parse::<i32>() {
247                worksheet7.write((row, col), num)?;
248            } else {
249                worksheet7.write((row, col), *data)?;
250            }
251            col += 1;
252        }
253        // Move on to the next worksheet row.
254        row += 1;
255    }
256
257
258    workbook.save_as("examples/autofilter.xlsx")?;
259
260    Ok(())
261}
Source

pub fn lt(val: &'a str) -> Self

Examples found in repository?
examples/autofilter.rs (line 131)
4fn main() -> WorkbookResult<()> {
5    // Prepare autofilter data
6    let text = fs::read_to_string("examples/autofilter_data.txt").unwrap();
7    let mut text = text.split("\n");
8    let headers: Vec<&str> = text.next().unwrap().split_whitespace().collect();
9    let mut data: Vec<Vec<&str>> = vec![];
10    for text in text { data.push(text.split_whitespace().collect()) }
11
12    // Create a new workbook
13    let mut workbook = Workbook::new();
14    // Add some worksheets
15    workbook.add_worksheet()?;
16    workbook.add_worksheet()?;
17    workbook.add_worksheet()?;
18    workbook.add_worksheet()?;
19    workbook.add_worksheet()?;
20    workbook.add_worksheet()?;
21
22    // Set up several sheets with the same data.
23    for worksheet in workbook.worksheets_mut() {
24        // Make the columns wider.
25        worksheet.set_columns_width("A:D", 12.0)?;
26        // // Make the header row larger.
27        worksheet.set_row_height_with_format(1, 20.0, &Format::default().set_bold())?;
28        // Make the headers bold.
29        worksheet.write_row("A1", &headers)?;
30    }
31
32    //
33    // Example 1. Autofilter without conditions.
34    //
35
36    let worksheet1 = workbook.get_worksheet_mut(1)?;
37    // Set the autofilter.
38    worksheet1.autofilter("A1:D51");
39    let mut row = 2;
40    for row_data in &data {
41        let mut col = 1;
42        for data in row_data {
43            if let Ok(num) = data.parse::<i32>() {
44                worksheet1.write((row, col), num)?;
45            } else {
46                worksheet1.write((row, col), *data)?;
47            }
48            col += 1;
49        }
50        // Move on to the next worksheet row.
51        row += 1;
52    }
53
54
55    //
56    // Example 2. Autofilter with a filter condition in the first column.
57    //
58    let worksheet2 = workbook.get_worksheet_mut(2)?;
59    // Set the autofilter.
60    worksheet2.autofilter("A1:D51");
61    // Add filter criteria.
62    let mut filters = Filters::new();
63    filters.and(Filter::eq("East"));
64    worksheet2.filter_column("A", &filters);
65    // Hide the rows that don't match the filter criteria.
66    let mut row = 2;
67    for row_data in &data {
68        let mut col = 1;
69        let data = row_data.get(0);
70        // Check for rows that match the filter.
71        if data != Some(&"East") {
72            // We need to hide rows that don't match the filter.
73            worksheet2.hide_row(row)?;
74        }
75        for data in row_data {
76            if let Ok(num) = data.parse::<i32>() {
77                worksheet2.write((row, col), num)?;
78            } else {
79                worksheet2.write((row, col), *data)?;
80            }
81            col += 1;
82        }
83        // Move on to the next worksheet row.
84        row += 1;
85    }
86
87    //
88    // Example 3. Autofilter with a filter condition in the first column.
89    //
90    let worksheet3 = workbook.get_worksheet_mut(3)?;
91    // Set the autofilter.
92    worksheet3.autofilter("A1:D51");
93    // Add filter criteria.
94    let mut filters = Filters::new();
95    filters.and(Filter::eq("East")).or(Filter::eq("South"));
96    worksheet3.filter_column("A", &filters);
97    // Hide the rows that don't match the filter criteria.
98    let mut row = 2;
99    for row_data in &data {
100        let mut col = 1;
101        let data = row_data.get(0);
102        // Check for rows that match the filter.
103        if data != Some(&"East") && data != Some(&"South") {
104            // We need to hide rows that don't match the filter.
105            worksheet3.hide_row(row)?;
106        }
107        for data in row_data {
108            if let Ok(num) = data.parse::<i32>() {
109                worksheet3.write((row, col), num)?;
110            } else {
111                worksheet3.write((row, col), *data)?;
112            }
113            col += 1;
114        }
115        // Move on to the next worksheet row.
116        row += 1;
117    }
118
119
120    //
121    // Example 4. Autofilter with filter conditions in two columns.
122    //
123    let worksheet4 = workbook.get_worksheet_mut(4)?;
124    // Set the autofilter.
125    worksheet4.autofilter("A1:D51");
126    // Add filter criteria.
127    let mut filters_a = Filters::new();
128    filters_a.and(Filter::eq("East"));
129    worksheet4.filter_column("A", &filters_a);
130    let mut filters_c = Filters::new();
131    filters_c.and(Filter::gt("3000")).and(Filter::lt("8000"));
132    worksheet4.filter_column("C", &filters_c);
133    // Hide the rows that don't match the filter criteria.
134    let mut row = 2;
135    for row_data in &data {
136        let mut col = 1;
137        let data = row_data.get(0);
138        // Check for rows that match the filter.
139        if data != Some(&"East") {
140            // We need to hide rows that don't match the filter.
141            worksheet4.hide_row(row)?;
142        }
143        for data in row_data {
144            if let Ok(num) = data.parse::<i32>() {
145                if num <= 3000 || num >= 8000 {
146                    worksheet4.hide_row(row)?;
147                }
148                worksheet4.write((row, col), num)?;
149            } else {
150                worksheet4.write((row, col), *data)?;
151            }
152            col += 1;
153        }
154        // Move on to the next worksheet row.
155        row += 1;
156    }
157
158
159    //
160    // Example 5. Autofilter with a filter list condition in one of the columns.
161    //
162    let worksheet5 = workbook.get_worksheet_mut(5)?;
163    // Set the autofilter.
164    worksheet5.autofilter("A1:D51");
165    // Add filter criteria.
166    let filters_list = Filters::eq(vec!["East", "North", "South"]);
167    worksheet5.filter_column("A", &filters_list);
168    // Hide the rows that don't match the filter criteria.
169    let mut row = 2;
170    for row_data in &data {
171        let mut col = 1;
172        let data = row_data.get(0);
173        // Check for rows that match the filter.
174        if data != Some(&"East") && data != Some(&"North") && data != Some(&"South") {
175            // We need to hide rows that don't match the filter.
176            worksheet5.hide_row(row)?;
177        }
178        for data in row_data {
179            if let Ok(num) = data.parse::<i32>() {
180                worksheet5.write((row, col), num)?;
181            } else {
182                worksheet5.write((row, col), *data)?;
183            }
184            col += 1;
185        }
186        // Move on to the next worksheet row.
187        row += 1;
188    }
189
190    //
191    // Example 6. Autofilter with filter for blanks.
192    //
193    let worksheet6 = workbook.get_worksheet_mut(6)?;
194    // Set the autofilter.
195    worksheet6.autofilter("A1:D51");
196    // Add filter criteria.
197    let filters = Filters::blank();
198    worksheet6.filter_column("A", &filters);
199    // Hide the rows that don't match the filter criteria.
200    let mut row = 2;
201    // Simulate a blank cell in the data.
202    data[5][0] = "";
203
204    for row_data in &data {
205        let mut col = 1;
206        let data = row_data.get(0);
207        // Check for rows that match the filter.
208        if data != Some(&"") {
209            // We need to hide rows that don't match the filter.
210            worksheet6.hide_row(row)?;
211        }
212        for data in row_data {
213            if let Ok(num) = data.parse::<i32>() {
214                worksheet6.write((row, col), num)?;
215            } else {
216                worksheet6.write((row, col), *data)?;
217            }
218            col += 1;
219        }
220        // Move on to the next worksheet row.
221        row += 1;
222    }
223
224    //
225    // Example 7. Autofilter with filter for non-blanks.
226    //
227    let worksheet7 = workbook.get_worksheet_mut(7)?;
228    // Set the autofilter.
229    worksheet7.autofilter("A1:D51");
230    // Add filter criteria.
231    let filters = Filters::not_blank();
232    worksheet7.filter_column("A", &filters);
233    // Hide the rows that don't match the filter criteria.
234    let mut row = 2;
235    // Simulate a blank cell in the data.
236
237    for row_data in &data {
238        let mut col = 1;
239        let data = row_data.get(0);
240        // Check for rows that match the filter.
241        if data == Some(&"") {
242            // We need to hide rows that don't match the filter.
243            worksheet7.hide_row(row)?;
244        }
245        for data in row_data {
246            if let Ok(num) = data.parse::<i32>() {
247                worksheet7.write((row, col), num)?;
248            } else {
249                worksheet7.write((row, col), *data)?;
250            }
251            col += 1;
252        }
253        // Move on to the next worksheet row.
254        row += 1;
255    }
256
257
258    workbook.save_as("examples/autofilter.xlsx")?;
259
260    Ok(())
261}
Source

pub fn ne(val: &'a str) -> Self

Auto Trait Implementations§

§

impl<'a> Freeze for Filter<'a>

§

impl<'a> RefUnwindSafe for Filter<'a>

§

impl<'a> Send for Filter<'a>

§

impl<'a> Sync for Filter<'a>

§

impl<'a> Unpin for Filter<'a>

§

impl<'a> UnwindSafe for Filter<'a>

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.