Thread: format cells
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Pamish Pamish is offline
external usenet poster
 
Posts: 2
Default format cells

I have this code below, in which I am trying to format cells with different
formats, is there a way of shortening this and maybe the change will make it
run faster.
These are sub heading that are suppose to be printed per produt info.

Range rg = oWorkSheet.get_Range("A" + LastRow.ToString(), "I" +
LastRow.ToString());

rg.Font.Bold = true;
rg.Font.Name = "Arial";
rg.Font.Size = 9;
rg.Cells.RowHeight = 30;

rg = oWorkSheet.get_Range("A" + LastRow.ToString(), Type.Missing);
rg.WrapText = false;
rg.Value2 = "string0";
LastRow++;
LastRow++;

rg = oWorkSheet.get_Range("A" + LastRow.ToString(), "I" +
LastRow.ToString());
rg.Font.Bold = true;
rg.Font.Name = "Arial";
rg.Font.Size = 9;
rg.Cells.RowHeight = 30;

rg = oWorkSheet.get_Range("A" + LastRow.ToString(), Type.Missing);
rg.WrapText = true;
rg.Value2 = "string1";

rg = oWorkSheet.get_Range("B" + LastRow.ToString(), Type.Missing);
rg.WrapText = false;
rg.ColumnWidth = 35;
rg.Value2 = "string2";

rg = oWorkSheet.get_Range("C" + LastRow.ToString(), Type.Missing);
rg.ColumnWidth = 35;
rg.WrapText = false;
rg.Value2 = "string3";

rg = oWorkSheet.get_Range("D" + LastRow.ToString(), Type.Missing);
rg.WrapText = true;
rg.Value2 = "string4";

rg = oWorkSheet.get_Range("E" + LastRow.ToString(), Type.Missing);
rg.WrapText = false;
rg.Value2 = "string5";

rg = oWorkSheet.get_Range("F" + LastRow.ToString(), Type.Missing);
rg.WrapText = false;
rg.ColumnWidth = 11;
rg.Value2 = "string6";

rg = oWorkSheet.get_Range("G" + LastRow.ToString(), Type.Missing);
rg.WrapText = false;
rg.ColumnWidth = 9;
rg.Value2 = "string7";