Jump to content

When using _Excel_RangeRead, the script copies only some cells.


Recommended Posts

When using _Excel_RangeRead, the script copies only some cells. Here's an example below:

In the demo, the fetched behavior of the script is:

Copy cell from one line, write to a text file;
Go back to worksheet, copy cell from next row, write to text file (So, successively)

However, as shown, there are some fields that are not copied.
What makes this happen?

 

excel1.png

excel2.png

Link to comment
Share on other sites

Link to comment
Share on other sites

  • Can you please post the exact _Excel_RangeRead statement you use?
  • Can you please post the value of @error and @extended after calling _Excel_RangeRead?
  • Did you read the wiki about Excel?

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

 

Link to comment
Share on other sites

1 hour ago, Nine said:

Show your script using post code method.  Add also your xls file, so we can test.  Make your script runable to us and eliminate all not related lines.  Thanks.

Ok, thank you

1 hour ago, water said:
  • Can you please post the exact _Excel_RangeRead statement you use?
  • Can you please post the value of @error and @extended after calling _Excel_RangeRead?
  • Did you read the wiki about Excel?

 

$campoInicio = InputBox("Linha INICIO", "Insira a Linha INICIO")
$campoFim = InputBox("Linha FIM", "Insira a Linha FIM")

$contaCadastroInicio = StringReplace($campoInicio, "a", "")
$contaCadastroFim = StringReplace($campoFim, "a", "")

$contaCadastroFim = $contaCadastroFim + 1

$excelPlanilha = _Excel_Open()
$sWorkbook = @ScriptDir & "\plan1.xlsx"
$workBookComplete = _Excel_BookOpen($excelPlanilha, $sWorkbook)

While $contaCadastroFim > $contaCadastroInicio
   $excelCodigo = _Excel_RangeRead($workBookComplete, Default, $campoInicio)
   $excelCompatibilidade = _Excel_RangeRead($workBookComplete, Default, StringReplace($campoInicio, "A", "G"))
   ConsoleWrite(">>>>> DESCRIÇÃO DA CÉLULA: " & $excelCompatibilidade & @CRLF)
   ConsoleWrite("<<<<< " & @CRLF)

   $iLength = StringLen($campoInicio)

   $contaCadastroInicio = $contaCadastroInicio + 1

   if $iLength == 2 Then
      $campoInicio = StringLeft($campoInicio,($iLength-1))&$contaCadastroInicio
      ElseIf $iLength == 3 Then
         $campoInicio = StringLeft($campoInicio,($iLength-2))&$contaCadastroInicio
   EndIf
WEnd

 

Thank you

plan1.xlsx

Edited by MateusAMOK
Translate
Link to comment
Share on other sites

  • Developers

@MateusAMOK, Could you please refrain from translating the quoted text?  Thanks. :) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Please set parameter 5 to True to use the transpose method of the Excel UDF. This removes limitations of Excel's transpose method.

Example:

_Excel_RangeRead($workBookComplete, Default, $campoInicio, 1, True)

 

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

 

Link to comment
Share on other sites

Your while loop is a tad complex for nothing :

While $contaCadastroFim > $contaCadastroInicio
   $excelCompatibilidade = _Excel_RangeRead($workBookComplete, Default, StringReplace($campoInicio, "A", "G"), 1, True)
   ConsoleWrite(">>>>> DESCRIÇÃO DA CÉLULA: " & $excelCompatibilidade & @CRLF)
   ConsoleWrite("<<<<< " & @CRLF)
   $contaCadastroInicio += 1
   $campoInicio = StringLeft($campoInicio, 1) & $contaCadastroInicio
WEnd

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...