서식 없이 자동 Excel 워크시트 내보내기

서식 없이 자동 Excel 워크시트 내보내기

각각의 시트 수가 다양한 수백 개의 Excel 파일이 있습니다. 각 시트를 CSV("각","셀","내부","따옴표"를 사용하는 것이 바람직하지만 필수는 아님)로 내보내야 합니다. 이상적으로는 열의 형식을 날짜로 다시 지정하지 않고 수행해야 합니다.

이것을 자동화하는 방법이 있나요? PowerShell을 사용하여 뭔가를 하려고 했지만 Excel과 관련하여 제가 본 모든 것은 COM 개체에 익숙하지 않고 불행하게도 지금은 배울 기회가 없기 때문에 피하려고 하는 COM 개체와 관련되어 있습니다.

답변1

MS powershellgallery.com의 모듈 중 하나를 사용하세요...

Find-Module -Name '*Excel*'

# Results
<#
Version     Name                                 Repository Description                                                                                       
-------     ----                                 ---------- -----------                                                                                       
7.1.1       ImportExcel                          PSGallery  PowerShell module to import/export Excel spreadsheets, without Excel....                          
0.1.12      PSWriteExcel                         PSGallery  Little project to create Excel files without Microsoft Excel being installed.                     
1.0.2       PSExcel                              PSGallery  Work with Excel without installing Excel                                                          
20.0.7654.0 ExcelCmdlets                         PSGallery  CData Cmdlets for Excel                                                                           
20.0.7654.0 ExcelServicesCmdlets                 PSGallery  CData Cmdlets for Excel Services                                                                  
0.1.6       BitTitan.Runbooks.Excel              PSGallery  PowerShell module for Excel-related functions and resources used in BitTitan Runbooks             
20.0.7654.0 ExcelOnlineCmdlets                   PSGallery  CData Cmdlets for Excel Online                                                                    
0.1.6       BitTitan.Runbooks.Excel.Beta         PSGallery  PowerShell module for Excel-related functions and resources used in BitTitan Runbooks             
0.6.9       ExcelPSLib                           PSGallery  Allow simple creation and manipulation of XLSX file                                               
0.0.4       Excelimo                             PSGallery  Simple project generating Excel Workbooks/Worksheets                                              
2.1         Read-ExcelFile                       PSGallery  PowerShell module to import Excel spreadsheets, without Excel....                                 
0.0.4       ProductivityTools.PSImportExcelToSQL PSGallery  Module takes all excel files in given directory and push the content to database. 
#>

... 파일을 읽으려면.

이것에 관해서는...

'...CSV(바람직하게는 "각", "셀", "내부", "인용부호"...'

...Export-Csv cmdlet을 사용하면 의도적으로 이 작업을 수행할 수 있습니다.

# Get specifics for a module, cmdlet, or function
(Get-Command -Name Export-Csv).Parameters
(Get-Command -Name Export-Csv).Parameters.Keys
Get-help -Name Export-Csv -Examples
Get-help -Name Export-Csv -Full
Get-help -Name Export-Csv -Online

웹 검색을 하면 다음과 같은 예가 표시됩니다.

'PowerShell은 Excel을 CSV로 변환합니다'

조회수 예시:

PowerShell 스크립트에서 Excel 파일을 CSV로 변환

ImportExcel 모듈 사용: 살펴보기

Import-Excel -Path .\ddm.xlsx -WorksheetName 'DDM Data' | 
Tee-Object -Variable xlData

관련 정보