0

I am converting files with the Import-Excel module in Powershell with this simple code:

Import-Excel -Path $PSScriptRoot\*.xlsx | Export-Csv $PSScriptRoot\file.csv -NoTypeInformation

The problem is this file has only two columns with data:

Articleno and Quantity

When the quantity is 0 (zero) in the first row, the module just exports the first column to csv; the Quantity column is completely ignored.

What am I doing wrong? Why does Import-Excel not export the 0 as well?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
ThoMo
  • 21
  • 3
  • Does this answer your question? [Not all properties displayed](https://stackoverflow.com/questions/44428189/not-all-properties-displayed) – iRon Mar 13 '20 at 13:29
  • Actually, if it is indeed related to the above mentioned question, I would qualify it as a [`Import-Excel`](https://github.com/dfinke/ImportExcel) bug as it should have property defined as well in the first row even it but is zero or null. – iRon Mar 13 '20 at 13:36
  • I am not able to reproduce your issue. Make sure you have the latest version of the `Import-Excel` module. Exclude `Export-Csv` (try default default display output). If the issue persists, I recommend you to raise the issue on the project site of `ImportExcel`: https://github.com/dfinke/ImportExcel – iRon Mar 13 '20 at 14:33
  • yeah correct. It seems more like a bug in Import-Excel. I hope the developers are reading here or i will have to make an issue here: https://github.com/dfinke/ImportExcel – ThoMo Mar 13 '20 at 14:35
  • So i updated the module with "Update-Module ImportExcel" to the latest Version in Powershell. When my first row contains a 0 for the quantity this row is not being imported. When i just import it in powershell i just see the first column, The second one is not displayed. When i change the quantity to 1 the second column is displayed. – ThoMo Mar 13 '20 at 14:39
  • I just checked the Version. It is 7.0.1 installed. – ThoMo Mar 13 '20 at 14:40
  • Are you using special cell formating? Can you share the `xlsx` file? – iRon Mar 13 '20 at 14:42
  • Well i thought of it as well but there are no formats in the file. I also removed the alignments and checked if the fields of the column have a special format. They are formated as "standard" in excel. The cells have no colors or backgrounds. No special fonts or anything else special about that file. I cannot share the file because of data sensibility. We use this file to check the stocks of a company. – ThoMo Mar 13 '20 at 14:54
  • Can you reproduce it with a fresh `xlsx` and random/ example data (and share that)? Also make sure you exclude add-ons and macros. In other words,, please try to create a [mcve]. – iRon Mar 13 '20 at 15:04
  • @iRon sure here is a very simple test and it also does not import the column as explained: https://mega.nz/#!OF1AxYha!fUPDiNY_I7e1_9dG59rMrKi2MpJh3dwiDaq4wzDghQA Here is also a Screenshot so you can see what happens at my Powershell: https://mega.nz/#!WUsihQSa!nEjqr9wK0WKBu1mzRYhUNJnRMX1L5wXvj5RNgoZpKLg – ThoMo Mar 14 '20 at 08:47

1 Answers1

0

ok the Problem is that "ImportExcel" always expects a header in the first row. When you use the "-NoHeader" Tag everything works fine and the 0 in the first row will be imported.

ThoMo
  • 21
  • 3