From 165ca73dccc5bd24068b561bdbb01f7467917fda Mon Sep 17 00:00:00 2001 From: albugowy15 Date: Thu, 23 May 2024 23:35:54 +0700 Subject: [PATCH] feat: remove excel.rs --- src/excel/excel.rs | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 src/excel/excel.rs diff --git a/src/excel/excel.rs b/src/excel/excel.rs deleted file mode 100644 index 68613b9..0000000 --- a/src/excel/excel.rs +++ /dev/null @@ -1,34 +0,0 @@ -use std::path::PathBuf; - -use anyhow::Context; -use calamine::{open_workbook, Data, Range, Reader, Xlsx}; - -use crate::db::repository::LecturerSubjectSessionMap; - -pub struct Excel { - pub range: Range, - pub lecturer_subjects_session_map: LecturerSubjectSessionMap, -} - -impl Excel { - pub fn new(file_path: &PathBuf, sheet_name: &str) -> anyhow::Result { - println!("Open excel file at {:?}", file_path); - let mut excel: Xlsx<_> = - open_workbook(file_path).with_context(|| "Cannot open excel file")?; - println!("Open excel sheet from {}", sheet_name); - let range = excel.worksheet_range(sheet_name)?; - println!("Successfully open excel file"); - Ok(Self { - range, - lecturer_subjects_session_map: LecturerSubjectSessionMap::default(), - }) - } - - pub fn with_repo_data( - mut self, - lecturer_subjects_session_map: LecturerSubjectSessionMap, - ) -> Excel { - self.lecturer_subjects_session_map = lecturer_subjects_session_map; - self - } -}