Damein Posted October 5, 2016 Share Posted October 5, 2016 Hey guys. Don't know if I'm doing this wrong but it seems I have it correct something is just amiss. I'm thinking its my lack of experience in Excel that is the problem. Trying to export a text file to Excel and everything works but the formatting is off on some data. Here are two screen shots. Before I stretch the column the Bin Number looks like this. After I stretch it it looks like this. Now its still wrong because this is the data its suppose to be inputting. Part Number|Part Description|Product Line|Bin Number|Count 1E-1041014|Label, Hazcom, Flooded, Med.|Deka|NA 1E-1041015|Label, Hazcom, Flooded, Lg.|Deka|NA 1E-1041017|Label, Hazcom, Agm/Gel, Med.|Deka|NA 1E-12214905|1/0 Thimble|NA|1E0302 1E-12214907|2/0 Thimble|NA|1E0303 1E-81214921|Cone, Single, Standard|NA|NA And this is the section of the script doing the export. Func _Export() Dim $ExportData[1][4] $ItemCount = _GUICtrlListView_GetItemCount($ListView) For $i = 0 To $ItemCount - 1 $GetPartNumberText = _GUICtrlListView_GetItemText($ListView, $i) $GetPartDescriptionText = _GUICtrlListView_GetItemText($ListView, $i, 1) $GetPartProductLineText = _GUICtrlListView_GetItemText($ListView, $i, 2) $GetPartBinNumberText = _GUICtrlListView_GetItemText($ListView, $i, 3) _ArrayInsert($ExportData, $i, $GetPartNumberText & "|" & $GetPartDescriptionText & "|" & $GetPartProductLineText & "|" & $GetPartBinNumberText) Next _ArrayDelete($ExportData, $ItemCount) SplashTextOn("Exporting...", "Exporting... please wait...", 300, 50, Default, Default, 33) Local $oExcel = _Excel_Open() If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpenText Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) FileDelete(@TempDir & "/Temp Part Database.txt") FileDelete(@ScriptDir & "/Temp Part Database.txt") _FileWriteFromArray(@TempDir & "/Temp Part Database.txt", $ExportData) _FileWriteToLine(@TempDir & "/Temp Part Database.txt", 1, "Part Number|Part Description|Product Line|Bin Number|Count") _FileWriteFromArray(@ScriptDir & "/Temp Part Database.txt", $ExportData) _FileWriteToLine(@ScriptDir & "/Temp Part Database.txt", 1, "Part Number|Part Description|Product Line|Bin Number|Count") Local $sTextFile = @TempDir & "/Temp Part Database.txt" FileOpen(@TempDir & "/Temp Part Database.txt") $oWorkbook = _Excel_BookOpenText($oExcel, $sTextFile, Default, $xlGeneralFormat, Default, Default, "|") If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpenText Example 1", "Error opening '" & $sTextFile & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Exit Else EndIf SplashOff() EndFunc ;==>_Export Any takers? Thanks! Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
BrewManNH Posted October 5, 2016 Share Posted October 5, 2016 The format of the 4th column is probably set to General format, you should format it to Text format. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
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