bindgridtoexcel();
gridtoexcel.Visible =
Response.Write("<iframe src='" + outURL + ".xls' style='display:none'></iframe>");
System.IO.StreamWriter sw =
HtmlTextWriter htw =
gridtoexcel.RenderControl(htw);
htw.Close();
sw.Close();
Microsoft.Office.Interop.Excel.Application excelApp =
excelApp.Visible =
Microsoft.Office.Interop.Excel.Workbook wb = excelApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
wb = excelApp.Workbooks.Open(path + ".htm",0,
Microsoft.Office.Interop.Excel.Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet) wb.ActiveSheet;
sheet.get_Range("A1","GE1").EntireColumn.AutoFit();
sheet.Cells.Font.Size = 8;
VBIDE.VBComponent module=
module = wb.VBProject.VBComponents.Add(VBIDE.vbext_ComponentType.vbext_ct_StdModule);
module.CodeModule.AddFromString(GetMacro());
wb.Application.Run("FormatSheet",Type.Missing,Type.Missing,Type.Missing,
Type.Missing,Type.Missing,Type.Missing,Type.Missing,
Type.Missing,Type.Missing,Type.Missing);
wb.SaveAs(path+".xls",43,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
wb.Close(
}
{
retVal+=("Sub FormatSheet()" + "\n");
retVal+=(" Range(\"A6:J13\").Select " + "\n");
retVal+=(" Selection.Font.ColorIndex = 3" + "\n");
retVal+=("End Sub");