General Error "DataTable.ImportSheet xlPath, xlSheet, "dTD"

1,042 views
Skip to first unread message

Demose

unread,
Oct 22, 2012, 12:13:43 AM10/22/12
to qtp-ele...@googlegroups.com
My Specs:
 
Vista Home Premium
32 bite
3 GB
QTP v11
 
Recieved the following error:
 
A general error occurred while importing sheet dTD from file C:\QTP\Excel\GasCalTestDataSheet.xls to sheet TestData.
Line (20): "datatable.ImportSheet xlPath, xlSheet, "dTD"".
 
Actual code below:
 
Option Explicit
Dim vendMiles, vstartMiles, vGallons, vCost, vMile_Gallon
Dim myP
Dim vURL
Dim xlPath, xlSheet
Dim vRows, i
vURL = "http://www.calculator.net/gas-mileage-calculator.html"
vendMiles = 15000
vstartMiles = 12000
vGallons = 5
vCost = 5
xlPath = "C:\QTP\Excel\GasCalTestDataSheet.xls"
xlSheet = "TestData"
  'Add new DT
  datatable.AddSheet "dTD"
  
  'Import our XL into DT
  datatable.ImportSheet xlPath, xlSheet, "dTD"
  
  'Get the Row Count
  vRow = datatable.GetSheet("dTD").GetRowCount()
  print "Rows are:"  &vRows
  For i =  1 to vRows
   datatable.GetSheet("dTD").SetCurrentRow(i)
   Print "Value for Rows" & i & "is" & datatable.Value("endMiles", "dTD")
  Next
  
  
  'Read the values from the DT
  
  'Perform the activies
  'Modify the results
  'Export the DT
  
  systemUtil.Run "iexplore.exe", vURL
  
  Set myP = Browser("IE").Page("Pg1")
  myP.WebEdit("endRead").Set vendMiles
  myP.WebEdit("startRead").Set vstartMiles
  myP.WebEdit("gallons").Set vGallons
  myP.WebEdit("gasPrice").Set vCost
  myP.Image("Calculate").Click
  myP.Sync
  
  vMile_Gallon = Browser("IE").Page("Pg1").WebElement("mGallon").GetROProperty("innertext")
  
  
  print "Value is:  "&vMile_Gallon

Browser("IE").Close

Function vVerify()
   print "Verify if the output is correct"
End Function
 
Any suggetions? 
 
 

Jenifer Anto

unread,
Oct 23, 2012, 10:49:57 PM10/23/12
to qtp-ele...@googlegroups.com
Check the same posted on Jan 26. It has solution. 

Thanks
Jenifer.

George

unread,
Oct 30, 2012, 5:11:34 AM10/30/12
to qtp-ele...@googlegroups.com
Hi, There is no problem with your code,  run it and it works fine, only need to check that path to the excelsheet is correct. also pls find the code enclosed.




Option Explicit
Dim vendMiles, vstartMiles, vGallons, vCost, vMile_Gallon
Dim myP
Dim vURL
Dim xlPath, xlSheet
Dim vRows, i
Dim vRow

vURL = "http://www.calculator.net/gas-mileage-calculator.html"
vendMiles = 15000
vstartMiles = 12000
vGallons = 5
vCost = 5

xlPath = "C:\Project_Gas_Cal\Calnet02.xls"

xlSheet = "TestData"

  'Add new DT
  datatable.AddSheet "dTD"
 
  'Import our XL into DT
  datatable.ImportSheet xlPath, xlSheet, "dTD"
 
  'Get the Row Count
  vRow = datatable.GetSheet("dTD").GetRowCount()
  print "Rows are "  & vRows

  For i =  1 to vRows
   datatable.GetSheet("dTD").SetCurrentRow(i)
   Print "Value for Rows" & i & "is" & datatable.Value("endMiles", "dTD")
  Next
 
 
  'Read the values from the DT
 
  'Perform the activies
  'Modify the results
  'Export the DT
 
  systemUtil.Run "iexplore.exe", vURL
 
  Set myP = Browser("IE").Page("Pg1")
  myP.WebEdit("endRead").Set vendMiles
  myP.WebEdit("startRead").Set vstartMiles
  myP.WebEdit("gallons").Set vGallons
  myP.WebEdit("gasPrice").Set vCost
  myP.Image("Calculate").Click
  myP.Sync
 
  vMile_Gallon = Browser("IE").Page("Pg1").WebElement("mGallon").GetROProperty("innertext")
 
 
  print "Value is:  "&vMile_Gallon

Browser("IE").Close

Function vVerify()
   print "Verify if the output is correct"
End Function



Any problem let me known.

Good luck
George




On Monday, October 22, 2012 5:13:43 AM UTC+1, Demose wrote:
My Specs:
 
Vista Home Premiume

George

unread,
Oct 30, 2012, 6:27:19 AM10/30/12
to qtp-ele...@googlegroups.com
Also very important when saving the excel sheet, make sure you save it to be compatible with 2007(.xls), and should work.


On Monday, October 22, 2012 5:13:43 AM UTC+1, Demose wrote:

satsingh

unread,
Nov 8, 2012, 1:50:50 PM11/8/12
to qtp-ele...@googlegroups.com
Hello ,
I hope your issue has been resolved, in case you are still stuck please follow the steps as mentioned here
http://testing-qtp-me.blogspot.in/2010/06/qtp-kb-2-general-error-when.html

For me this has worked.

Thanks
Reply all
Reply to author
Forward
0 new messages