Bitten Posted May 23, 2015 Posted May 23, 2015 Hi,I'm having a weird issue i can't figure out.When i use _Excel_RangeWrite to outout my array to excel, i get a different value for one of the cells, than the actual array holds.The code i use is:Func OutputExcel($array) Local $oAppl = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookNew($oAppl) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oAppl) Exit EndIf _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $array) $oAppl.ActiveSheet.Columns("A:C").AutoFit EndFuncI have an array that looks like this:0|240|12.05 1|170|8.54 2|98|4.92 3|95|4.77 4|81|4.07 5|64|3.21 6|64|3.21 7|43|2.16 8|38|1.91 9|27|1.36 11-20|281|14.11 21-30|173|8.69 31+|617|30.99However, when i output it to excel, the value for "11-20" is replaced with "44136" ( see image ).I'm guessing this has something to do with the format of the value, but i can't seem to make it work.Any idea's are welcome.
water Posted May 23, 2015 Posted May 23, 2015 What you see in the Excel GUI after entering data (either manually or by the Excel UDF) depends on the format you have set for the cells or by the way the data is interpreted by Excel when the cell format is set to Default.I assume Execel interprets the data "11-20" as date (20th of November) and 44216 is the internal representation of this date.Set the cell format for "Numbers" (or whatever it is called in an engl./american Excel version) and see what you get. Bitten 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Bitten Posted May 23, 2015 Author Posted May 23, 2015 So simple!I set the format to text, and now i get the values i wanted Awesome. I was on the right track, but im a noob when it comes to excel.
water Posted May 23, 2015 Posted May 23, 2015 If all problems could be fixed so easily My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now