ahmeddzcom Posted February 28, 2022 Share Posted February 28, 2022 Hello I Get 5 text files From Excel file Then I will have More then 36000 Lines in 5 Files TXT I need specific range I use this code : #include <Excel.au3> #include <File.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir&"\Price.xlsx") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error opening") _FileWriteFromArray(@ScriptDir&"\Tmp_Price1.txt",_Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("B")), 0) _FileWriteFromArray(@ScriptDir&"\Tmp_Price2.txt",_Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("D")), 0) _FileWriteFromArray(@ScriptDir&"\Tmp_CODE.txt",_Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("F")), 0) _FileWriteFromArray(@ScriptDir&"\Tmp_PriceDate.txt",_Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("J")), 0) _FileWriteFromArray(@ScriptDir&"\Tmp_Price3.txt",_Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("L")), 0) $Price1 = @ScriptDir&"\Tmp_Price1.txt" $Price2 = @ScriptDir&"\Tmp_Price2.txt" $CODE = @ScriptDir&"\Tmp_CODE.txt" $PriceDate = @ScriptDir&"\Tmp_PriceDate.txt" $Price3 = @ScriptDir&"\Tmp_Price3.txt" For $i = 1 to _FileCountLines($PriceDate) If FileReadLine($PriceDate, $i) = 0 Then If FileReadLine($CODE, $i) = 2 Then FileWrite(@ScriptDir&"\Revdr1.txt",FileReadLine($Price1, $i)&@CRLF) FileWrite(@ScriptDir&"\Revdr2.txt",FileReadLine($Price2, $i)&@CRLF) FileWrite(@ScriptDir&"\Revdr3.txt",FileReadLine($Price3, $i)&@CRLF) EndIf If FileReadLine($CODE, $i) = 3 Then FileWrite(@ScriptDir&"\Cons1.txt",FileReadLine($Price1, $i)&@CRLF) FileWrite(@ScriptDir&"\Cons2.txt",FileReadLine($Price2, $i)&@CRLF) FileWrite(@ScriptDir&"\Cons3.txt",FileReadLine($Price3, $i)&@CRLF) EndIf EndIf Next This take a long time Please any fast other way thanx Price.xlsx Link to comment Share on other sites More sharing options...
Solution Nine Posted March 1, 2022 Solution Share Posted March 1, 2022 Maybe this : expandcollapse popup#include <Excel.au3> #include <File.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Price.xlsx") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error opening") Local $aExcel = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("B:L")) $hRevdr1 = FileOpen(@ScriptDir & "\Revdr1.txt", $FO_OVERWRITE) $hRevdr2 = FileOpen(@ScriptDir & "\Revdr2.txt", $FO_OVERWRITE) $hRevdr3 = FileOpen(@ScriptDir & "\Revdr3.txt", $FO_OVERWRITE) $hCons1 = FileOpen(@ScriptDir & "\Cons1.txt", $FO_OVERWRITE) $hCons2 = FileOpen(@ScriptDir & "\Cons2.txt", $FO_OVERWRITE) $hCons3 = FileOpen(@ScriptDir & "\Cons3.txt", $FO_OVERWRITE) For $i = 0 To UBound($aExcel) - 1 If $aExcel[$i][8] = 0 Then If $aExcel[$i][4] = 2 Then FileWrite($hRevdr1, $aExcel[$i][0] & @CRLF) FileWrite($hRevdr2, $aExcel[$i][2] & @CRLF) FileWrite($hRevdr3, $aExcel[$i][10] & @CRLF) EndIf If $aExcel[$i][4] = 3 Then FileWrite($hCons1, $aExcel[$i][0] & @CRLF) FileWrite($hCons2, $aExcel[$i][2] & @CRLF) FileWrite($hCons3, $aExcel[$i][10] & @CRLF) EndIf EndIf Next FileClose($hRevdr1) FileClose($hRevdr2) FileClose($hRevdr3) FileClose($hCons1) FileClose($hCons2) FileClose($hCons3) It is taking less than 8 secs...But I didn't made much verification. ahmeddzcom 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
ahmeddzcom Posted March 1, 2022 Author Share Posted March 1, 2022 (edited) Mr. @Nine thank you so so much . This is exactly what I was looking for 😃. ( It is taking less than 8 secs...But I didn't made much verification. ) No 😁 It is taking less than 1 secs. Edited March 1, 2022 by ahmeddzcom 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