ImportExcel icon indicating copy to clipboard operation
ImportExcel copied to clipboard

Excel can't save , and read wrong data

Open Mitdac1989 opened this issue 4 years ago • 6 comments

Hi everyone. I am newbie in PowerShell, I only try to edit cell A1 in Excel file and check cell B1 have Formula connect with cell A1 , I want get value B1 when I change value in A1 Problem is , I can change value in Cell A1 but the value in B1 not change even I save or save as or close excel for autosave, but it still not get correct value in B1 Capture1

Mitdac1989 avatar Aug 25 '22 04:08 Mitdac1989

Hi, I faintly remember having had a similar issue, which was resolved when I used the switch -calculate when closing the excel package, see also https://github.com/dfinke/ImportExcel/blob/master/mdHelp/en/close-excelpackage.md#-calculate

TWalijew avatar Aug 25 '22 11:08 TWalijew

Thank you so much , it work, I have other question, Could I calculate without closing the excel then i can get value :D, it will be great, because I need use excel calculate alot and get data from excel. I try to build automation excel with PowerShell Thank you so much

Mitdac1989 avatar Aug 26 '22 01:08 Mitdac1989

I have other question , Sorry I ask alot question , do we have document about those functions or syntax like picture. If have those document I can learn faster Thank you so much. image

Mitdac1989 avatar Aug 26 '22 01:08 Mitdac1989

Thank you so much , it work, I have other question, Could I calculate without closing the excel then i can get value :D, it will be great, because I need use excel calculate alot and get data from excel. I try to build automation excel with PowerShell Thank you so much

Alright, the diffcult questions! :-) $xl=Open-ExcelPackage -Path .\test.xlsx $ws=$xl.Workbook.Worksheets['ABC'] $ws.cells["D1"].Value=23.998 #Formula in E1: $ws.cells["E1"].formula="+d1*2" [OfficeOpenXml.CalculationExtension]::Calculate($ws.cells["E1"]) $ws.cells["E1"].value

To answer your other question:

  1. Search the web
  2. https://github.com/dfinke/ImportExcel/tree/master/mdHelp/en
  3. And if you need to dig deeper: https://epplussoftware.com/docs/5.3/api/OfficeOpenXml.html
  4. Try & Error (without going ballistic) :-)

TWalijew avatar Aug 26 '22 07:08 TWalijew

Thank you so much, it work :D

Mitdac1989 avatar Aug 26 '22 08:08 Mitdac1989

Thank you @TWalijew was heading off to test the Calculate method. This looks like a good candidate for the Examples folder 😉

dfinke avatar Aug 26 '22 17:08 dfinke