반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 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 |
Tags
- Uipath 기초
- 왕초보 파이썬 실행
- Selenium 셀렉터잡기
- Uipath 설치방법
- 네이버커머스API
- 파이썬 가상환경 설치방법
- pywinauto 윈도우제어
- 커머스API
- 네이버 로그인 하기
- pycdc.exe
- 네이버 로그인 영수증 해결
- Element is not clickable at point
- vscode venv 설치
- pywinauto
- 파이썬 환경설정
- 네이버매물크롤링
- pywinauto 윈도우
- 날짜 정규식
- Python
- 네이버부동산크롤링
- 파이썬 가상환경 설치
- venv 설치
- uipath 입문
- 파이썬 네이버 로그인
- selenium
- pycdas.exe
- 파이썬네이버부동산
- UiPath
- 네이버 로그인 캡챠해결
- 가상환경설치
Archives
- Today
- Total
콘솔워크
xlsx, xls 변환 함수 본문
반응형
import win32com.client as win32
def xls_to_xlsx(source):
if not str(source).find("xls") > -1:
return
excel = win32.Dispatch("Excel.Application")
# excel = win32.gencache.EnsureDispatch("Excel.Application")
wb = excel.Workbooks.Open(source)
xlsx_file = source + "x"
if os.path.isfile(xlsx_file):
os.remove(xlsx_file)
wb.SaveAs(xlsx_file, FileFormat=51) # FileFormat = 51 is for .xlsx extension
wb.Close() # FileFormat = 56 is for .xls extension
excel.Application.Quit()
def xlsx_to_xls(source):
if not str(source).find("xlsx") > -1:
return
if not os.path.isfile(source):
return
# excel = win32.gencache.EnsureDispatch("Excel.Application")
excel = win32.Dispatch("Excel.Application")
wb = excel.Workbooks.Open(source)
print("xlsx_to_xls")
xls_file = source[:-1]
if os.path.isfile(xls_file):
os.remove(xls_file)
wb.SaveAs(xls_file, FileFormat=56) # FileFormat = 51 is for .xlsx extension
wb.Close() # FileFormat = 56 is for .xls extension
excel.Application.Quit()
os.remove(source)
return xls_file
반응형
'프로그래밍 > python' 카테고리의 다른 글
dataframe에서 값이 일치하는 열이 있는 행을 검색하는 코드 (0) | 2023.05.10 |
---|---|
파이썬 한 폴더 내에 파일명 + 확장자가 포함된 것중 가장 최근 파일 가져오기 (0) | 2023.05.09 |
대괄호 안의 문자를 추출하는 함수 (0) | 2023.05.04 |
pyinstaller icon 깨질때 (0) | 2023.05.04 |
python에서 dict를 str로 바꾸는 여러가지 방법 (0) | 2023.05.02 |