1use crate::args::Head;
2use crate::utils::cli_result::CliResult;
3use crate::utils::constants::COMMA;
4use crate::utils::filename::new_path;
5use crate::utils::reader::ExcelReader;
6use crate::utils::writer::Writer;
7
8impl Head {
9 pub fn excel_run(&self) -> CliResult {
10 let path = &self.path();
11 let out = new_path(path, "-head").with_extension("csv");
12 let mut wtr = Writer::file_or_stdout(self.export, &out)?;
13 let range = ExcelReader::new(path, self.sheet)?;
14
15 range
17 .iter()
18 .take(self.n + 1 - (self.no_header as usize))
19 .for_each(|r| {
20 wtr.write_excel_line_unchecked(r, COMMA);
21 });
22
23 if self.export {
24 println!("Saved to file: {}", out.display())
25 }
26
27 Ok(())
28 }
29}