Forum Discussion
HKosova
Alumni
12 years agoHi Anik,
I can suggest a few options:
1. Use CSV files (text files with comma-separated values) instead of Excel files. Excel can open CSV files, too.
2. Use some .NET or Java library that can read/write Excel files. For example:
.NET - NPOI
Java - POI, JExcelApi, OpenXLS
You can connect to external libraries from TestComplete via CLR Bridge and Java Bridge.
3. Install ACE data provider and work with Excel files as with databases. Here's an example:
Working with MS Excel(xls / xlsx) Using MDAC and Oledb
How to read or write excel file using ACE OLEDB data provider?
I can suggest a few options:
1. Use CSV files (text files with comma-separated values) instead of Excel files. Excel can open CSV files, too.
2. Use some .NET or Java library that can read/write Excel files. For example:
.NET - NPOI
Java - POI, JExcelApi, OpenXLS
You can connect to external libraries from TestComplete via CLR Bridge and Java Bridge.
3. Install ACE data provider and work with Excel files as with databases. Here's an example:
You can read more about this approach here:
// JScript
function Test()
{
// Before running the script, create a Excel file with some number in cell A1,
// and specify the file name here:
var strFileName = "C:\\Work\\Book1.xlsx";
// Open a database connection to the Excel file
var conn = Sys.OleObject("ADODB.Connection");
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Mode=ReadWrite;"
+ "Data Source='" + strFileName
+ "';Extended Properties='Excel 8.0;HDR=NO';";
conn.Open();
// Change the value in the A1 cell
var strSQL = "UPDATE [Sheet1$A1:A1] SET F1 = 42";
conn.Execute(strSQL);
// Append a row at the end
strSQL = "INSERT INTO [Sheet1$] Values (15);";
conn.Execute(strSQL);
conn.Close();
}
Working with MS Excel(xls / xlsx) Using MDAC and Oledb
How to read or write excel file using ACE OLEDB data provider?