class ExcelFile(): def __init__(self): # self.baseapp = None self.baseapp = ExcelApp() self.app = self.baseapp.app self.wb = ExcelWorkBook() self.ws = None def open_excelapp(self): self.baseapp = ExcelApp() # @stop_watch def open_workbook(self, filepath): self.wb.open_wb(self.app, filepath) self.ws = self.wb.xlws return self.ws def close_app_wb(self): self.wb.close_workbook() def close_app(self): self.app.quit() def close_baseapp(self): self.baseapp.close_App() def close(self): self.close_app_wb() self.close_baseapp()
class main(): def __init__(self, filename): self.baseapp = ExcelApp() self.app = self.baseapp.app self.wb = ExcelWorkBook() self.wb.open_wb(self.app, filename) self.ws = self.wb.xlws def close(self): self.wb.close_workbook() self.baseapp.close_App()
class Excels(): def __init__(self): self.__def_dir = "DeskTop" self.__ftype = [("Excel2007ファイル", "*.xlsx")] self.picker = GetFile(self.__def_dir, self.__ftype) self.file_list = self.get_file_list() self.baseapp = ExcelApp() self.app = self.baseapp.app self.wb = ExcelWorkBook() self.item_shelf = ItemShelf() self.ws = None self.dto = None def get_file_list(self): result = self.picker.get_files() if result is False: quit() else: self.file_list = list(result) def open_wb(self, filepath): self.wb.open_wb(self.app, filepath) self.ws = self.wb.xlws return self.ws def close_app_wb(self): self.wb.close_workbook() def close_app(self): self.app.quit() def close_baseapp(self): self.baseapp.close_App() def close(self): self.close_app_wb() self.close_baseapp() def get_multi_dto(self, lists): n_cores = multi.cpu_count() with ProcessPoolExecutor(max_workers=n_cores) as executor: result = executor.map(self.get_excel_dto, lists) self.item_shelf.append(result) def test_code(self, lists): with Pool(4) as p: ret = p.map(self.get_excel_dto, lists) self.item_shelf.append(ret)
class ExcelFile(): def __init__(self): self.base_app = ExcelApp() self.app = self.base_app.app self.wb = ExcelWorkBook() self.ws = None def open_workbook(self, filepath): self.wb.open_wb(self.app, filepath) self.ws = self.wb.xlws def close_workbook(self): self.wb.close_workbook() def close_baseapp(self): self.base_app.close_App() def close(self): self.close_workbook() self.close_baseapp()