Read from an excel file(Importing cell values and print in consol)

 


Suhas_C - Tue Jul 04 06:02:37 EDT 2017

Re: Read from an excel file(Importing cell values and print in consol)
HPM2BP - Wed Jul 05 08:32:50 EDT 2017

I suggest writing a VBA script that creates a temp txt file, then importing that txt file with DXL. I've been using this method for a while, started using rich text too. Takes for a while, but it'll be worth it. (kind of)

 

Also you can try the OleObject method, however that may require admin rights, which is not always available.

Re: Read from an excel file(Importing cell values and print in consol)
pommCannelle - Thu Jul 06 04:59:35 EDT 2017

You should try this very nice page ...
The Excel Functions sections contains all the necessary stuff ... using the provided .inc files, you should be abble to write something like :

bool excelInit() {
   objExcel = connectToApp(cObjExcelApplication, "Excel")
   if (null objExcel) return false

   makeVisible objExcel

   // get workbooks collection 
   checkRes(oleGet(objExcel,cPropertyWorkbooks,objWorkbooks))
   if (null objWorkbooks) {
      ack "Unable to get workbooks collection"
      return false
   }

   // add one 
   checkRes(oleMethod(objWorkbooks, cMethodAdd))

   // get active workbook 
   checkRes(oleGet(objExcel,cPropertyActiveWorkbook,objWorkbook))
   if (null objWorkbook) {
      ack "Unable to get active workbook"
      return false
   }
   // get active sheet 
   checkRes(oleGet(objWorkbook,cPropertyActiveSheet,objSheet))
   if (null objSheet) {
      ack "Unable to get active sheet"
      return false
   }

   return true
}

 

Now you can open Excel and use all the provided functions ... and you should be abble to read/write an excel file properly ;)

Re: Read from an excel file(Importing cell values and print in consol)
Suhas_C - Fri Jul 07 00:54:04 EDT 2017

HPM2BP - Wed Jul 05 08:32:50 EDT 2017

I suggest writing a VBA script that creates a temp txt file, then importing that txt file with DXL. I've been using this method for a while, started using rich text too. Takes for a while, but it'll be worth it. (kind of)

 

Also you can try the OleObject method, however that may require admin rights, which is not always available.

Thanks for the reply :)

But I tried converting the excel into CSV file and read the data using dxl code and it works fine.

Re: Read from an excel file(Importing cell values and print in consol)
Suhas_C - Fri Jul 07 00:55:38 EDT 2017

pommCannelle - Thu Jul 06 04:59:35 EDT 2017

You should try this very nice page ...
The Excel Functions sections contains all the necessary stuff ... using the provided .inc files, you should be abble to write something like :

bool excelInit() {
   objExcel = connectToApp(cObjExcelApplication, "Excel")
   if (null objExcel) return false

   makeVisible objExcel

   // get workbooks collection 
   checkRes(oleGet(objExcel,cPropertyWorkbooks,objWorkbooks))
   if (null objWorkbooks) {
      ack "Unable to get workbooks collection"
      return false
   }

   // add one 
   checkRes(oleMethod(objWorkbooks, cMethodAdd))

   // get active workbook 
   checkRes(oleGet(objExcel,cPropertyActiveWorkbook,objWorkbook))
   if (null objWorkbook) {
      ack "Unable to get active workbook"
      return false
   }
   // get active sheet 
   checkRes(oleGet(objWorkbook,cPropertyActiveSheet,objSheet))
   if (null objSheet) {
      ack "Unable to get active sheet"
      return false
   }

   return true
}

 

Now you can open Excel and use all the provided functions ... and you should be abble to read/write an excel file properly ;)

I tried this one .but it was showing some null parameter was passed while getting cell value.

Re: Read from an excel file(Importing cell values and print in consol)
pommCannelle - Fri Jul 07 10:23:00 EDT 2017

Suhas_C - Fri Jul 07 00:55:38 EDT 2017

I tried this one .but it was showing some null parameter was passed while getting cell value.

Hmm ... you tell the truth :)

 

I used this link in 2011, so i just do not remember what i've done at this moment to make it works... but you may try to replace

clear(args)

with something like 

if ( ! null args ) clear(args);
else args = create()

;)