
Ich habe mehrere hundert Excel-Dateien mit jeweils unterschiedlich vielen Blättern. Ich muss jedes Blatt als CSV exportieren (vorzugsweise mit „jede“, „Zelle“, „in“, „Anführungszeichen“, aber nicht notwendig), idealerweise ohne dass eine der Spalten als Datum neu formatiert wird.
Gibt es eine Möglichkeit, dies zu automatisieren? Ich habe versucht, etwas mit PowerShell zu machen, aber alles, was ich zu Excel gesehen habe, betrifft COM-Objekte, die ich zu vermeiden versuche, weil ich mit ihnen nicht vertraut bin und im Moment leider keine Zeit habe, etwas darüber zu lernen.
Antwort1
Verwenden Sie eines der Module von 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.
#>
... um die Dateien zu lesen.
Was das betrifft...
„…CSV (vorzugsweise mit „each“, „cell“, „in“, „quotes“…“
... die Verwendung des Cmdlets „Export-Csv“ tut dies per Design
# 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
Eine Websuche würde Ihnen Beispiele anzeigen:
Beispieltreffer:
Konvertieren einer Excel-Datei in CSV aus einem PowerShell-Skript
Import-Excel -Path .\ddm.xlsx -WorksheetName 'DDM Data' |
Tee-Object -Variable xlData