Ask a Question

Not able to grab data from Excel using TestComplete with wrapped text using Excel.Open("filename")..

MatthewB
Occasional Contributor

Not able to grab data from Excel using TestComplete with wrapped text using Excel.Open("filename")..

We are using the Excel.Open("FileName").SheetByIndex(0).Cell("A",6).Value to grab data from excel.  The method works overall, but does not capture the wrapped text from Excel.  The result of the data gets only the top row of data in the cell if the data has multiple rows within the cell due to format wrapping.  

 

https://s3.amazonaws.com/webtocasefiles/2023/df50c321-d7a4-01b4-c9a0-3b2a829a6f9f/2023_05_09-11_49_3...

 

https://s3.amazonaws.com/webtocasefiles/2023/df50c321-d7a4-01b4-c9a0-3b2a829a6f9f/2023_05_11-12_19_1...

 

 

I also want to include that we are not using the full version of Excel. We are only using the runtime available from Microsoft:

https://urldefense.com/v3/__https://support.microsoft.com/en-us/office/download-and-install-microsof... <https://urldefense.com/v3/__https://support.microsoft.com/en-us/office/download-and-install-microsof...>

 

We are also referring to the example provided in the SmartBear documentation:

https://urldefense.com/v3/__https://support.smartbear.com/testcomplete/docs/testing-with/working-wit... <https://urldefense.com/v3/__https://support.smartbear.com/testcomplete/docs/testing-with/working-wit...>

 

Specifically, the section about Excel Object.

20 REPLIES 20
rraghvani
Champion Level 2

I think your Excel data seems to have a carriage return.

rraghvani_0-1684250624164.png

Log.Message() method will not display multiple lines.

 

If you try the code example from Excel.Open Method, and inspect the variable values in debug mode, it will contain the full value.

 

Also, avoid many Excel.Open methods like you have done - unless you are just showing an example of the issue.

 

Can you hover your mouse of the message, it should show a tooltip containing the entire string.

MatthewB
Occasional Contributor

Do you expect that the variable should be able to store that value with the carriage return ?  We're trying to get the return value to compare it.

MatthewB
Occasional Contributor

The values in debug mode do not show up as expected somehow.  Do we need to reference Excel differently using a Javascript method or something? 

MatthewB
Occasional Contributor

I would think that the WordWrap is causing the issue.  Not sure we can go about fixing this problem at this point.  We tried to remove the \n carriage return, but it was more related to the wrap.

MatthewB_0-1684262680080.png

 

MatthewB_2-1684262829018.png

 

rraghvani
Champion Level 2

Are you able to attach your Excel spreadsheet, so that I can have a quick look?

A_Roskoshnyi
Contributor

Try some modify your code:

var excel = Sys.OleObject("Excel.Application");
excel["Workbooks"].Open(path_to_excel_file);
excel["Sheets"](name_of_sheet).Select();

//Get value from cell with rowIndex = 6, columnIndex = 1
var text_from_cell = aqConvert.VarToStr(excel["Cells"](6,1));
MatthewB
Occasional Contributor

Here is another file that shows the data.  

MatthewB
Occasional Contributor

We are trying to not have Excel loaded onto the VM and use the Excel method from SmartBear.  We have already used the "Excel.Application" before and it was working.  

rraghvani
Champion Level 2

Using the same code as you have written, all the text is shown. I can see from the tooltip, that there is a carriage return in some of your cells.

rraghvani_0-1684337034527.png

 

cancel
Showing results for 
Search instead for 
Did you mean: