Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Unable to Bold or Italicize Exported Excel
posted

Hi!

I have a process which uses the Excel object to create worksheets in a workbook. (I'm using Infragistics v.8.1).  I created the data in the worksheets from a DataTable.  I tried exporting the data 2 ways.  The first way I manually exported the data:

 

 

 

 

 

 

 

 

 

// create row and col variables for saving in the worksheet.

int row = 0;

 

 

int

col = 0;

 

 

// First print out the column heading

foreach (DataColumn dc in dtUCellInfoByEngineer.Columns)

{

worksheet.Rows[row].Cells[col].CellFormat.Locked =

 

ExcelDefaultableBoolean

.False;

worksheet.Rows[row].Cells[col++].Value = String.Format("{0}", dc.ColumnName);

}

 

 

 

// Print out the data, iterating over each row in the view

int numCols = dtUCellInfoByEngineer.Columns.Count;foreach(DataRowView drv in dvUCellInfo)

{

row++;

col = 0;

 

for (int i=0; i<numCols; i++)

{

worksheet.Rows[row].Cells[col].CellFormat.Locked =

 

ExcelDefaultableBoolean

.False;

worksheet.Rows[row].Cells[col++].Value = drv[i];

}

}

It was fairly straightforward.  However, when we tried to load the excel spreadsheet into an automatic processor, it spit it out.  It said that it was unable to change/update the italics on the first line of the file (that is part of the processing of the excel file that it needs to do).  So we looked at it via Excel 2003.  Sure enough, when you tried to click on the Italics button or the bold button, NOTHING happened. (In Excel 2007 it worked, and going through the font menu, but not the buttons).  If you clicked on the Underline button, then it underlined the contents of the cell, and only then could you italicize or bold the contents of the cell.  Meaning, sure enough, the cell WAS locked in some form/fashion.

So I tried another way to generate the data on the worksheet:

UltraGrid grid = new UltraGrid();

grid.BindingContext =

 

new BindingContext

();

grid.DataSource = dvUCellInfo;

grid.DataBind();

 

UltraGridExcelExporter export = new UltraGridExcelExporter();

export.Export(grid, worksheet);

This time, the data itself was changeable.  The first line (which is the header of the table, and the part which needs to be updateable), however, was immutable as before, in relation to the Italics button and Bold button.  I tried comparing the Cell Format of the cells in Excel 2003 to see if I could find a difference between them, but, alas, to no avail, I didn't see any difference between them.  Do you know why it would be generated that way?  Can I control it?  From the results, it does seem that I should be able to.  Unfortunately, this is a 'show-stopper' for the project.

Thank you for your help and consideration.

Zev

Parents
No Data
Reply Children
No Data