dfinke/ImportExcel

Corruption/Loss of Data with Excel Data Types (stock, currency, etc)

dbytes opened this issue · 5 comments

dbytes commented

The following will cause corruption or loss of data to an existing sheet (sheet1) that contains Excel Data Types such as stocks.

$data = ConvertFrom-Csv @'
Ticker,Date,Units
VOO,11/22/2024,10
VTI,11/20/2024,50
'@

$data | Export-Excel -Path 'invest.xlsx' -WorksheetName 'import' #imports to a new sheet

Before:
before

After:
after

Excel Workbook as example data:
invest.xlsx

dfinke commented

Does -append do what you need?

dbytes commented

No, that has the same issue.

dfinke commented

if you have plain text in the col A. does it work? not sure of the image and/or the ; colon

dbytes commented

If it was plain text it is fine, but this has been converted to an Excel Data Type.

Setting up the data type, you would enter a ticker such as VOO as plain text in A1 and then convert it. I've included a GIF to show how to set this up if you were not aware.

EDIT: I can update this Workbook without issue when working directly with the COM Object.

2024-11-22_08-38-11

dfinke commented

Yeah, the COM approach is completely different. I don't think the translation in the EPPlus layer is handling it and I don't have control over that.