Forum Discussion

_angelo's avatar
_angelo
Occasional Contributor
16 years ago

Reading text from excel file while keeping formatting using JScript

Hello,



I'm trying programmatically trying to read some data from an Excel file. My code is in JScript and based on the example in the TestComplete help file (see below). The problem I have is that the formatting from the Excel file (bold, underline, and italics) is removed when I read the cells of the Excel file into a String. Is there any way to keep that formatting?



Thank you in advance.



Angelo



PS - Below is the code from TestComplete help that mine is based on.



var RecNo;

 

// Posts data to the log (helper routine)

function ProcessData()

{

  var Fldr, i;

 

  Fldr = Log.CreateFolder("Record: " + aqConvert.VarToStr(RecNo));

  Log.PushLogFolder(Fldr);

 

  for(i = 0; i < DDT.CurrentDriver.ColumnCount; i++)

    Log.Message(DDT.CurrentDriver.ColumnName(i) + ": " + aqConvert.VarToStr(DDT.CurrentDriver.Value(i)));

 

  Log.PopLogFolder();

  RecNo = RecNo + 1;

}

 

// Creates the driver (main routine)

function TestDriver()

{

  var Driver;

 

  // Creates the driver

  // If you connect to an Excel 2007 sheet, use the following method call:

  // Driver = DDT.ExcelDriver("C:\\MyFile.xls", "Sheet1", true);

  Driver = DDT.ExcelDriver("C:\\MyFile.xls", "Sheet1");

 

  // Iterates through records

  RecNo = 0;

  while (! Driver.EOF() )

  {

    ProcessData(); // Processes data

    Driver.Next(); // Goes to the next record

  }

 

  // Closing the driver

  DDT.CloseDriver(Driver.Name);

}