here is the code:
try
{
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense("Aspose.Cells.lic");
dsRecognition = new DataSet();
dsRecognition = spgCon.GetDataSet("SPG_GENERAL_PKG", "GetNominationTable", "recognition", "cur_nomination");
int iRow = dsRecognition.Tables[0].Rows.Count; // # of data rows
int iCol = dsRecognition.Tables[0].Columns.Count; // # of data columns
if (iRow <= 0)
{
lblError.Text = "Recognition report is not available.";
lblError.Visible = true;
}
else
{
//Creating a Workbook object
Workbook templateWorkbook = new Workbook();
Workbook workbook = new Workbook();
string path = MapPath("..");
string tempFile = path + @"\Template\Recognition.xls";
templateWorkbook.Open(tempFile);
// copy it first
workbook.Copy(templateWorkbook);
// close the template
templateWorkbook.Save(tempFile, FileFormatType.Default);
Worksheet rawSheet = workbook.Worksheets[8]; // Raw Data sheet
Cells cells = rawSheet.Cells;
cells.ImportDataTable(dsRecognition.Tables[0], false, 1, 0, iRow, iCol); //Import data without heading and start at row 1(set it to false)
// set all row height for raw data sheet
for (int i = 0; i < iRow + 3; i++)
cells.SetRowHeight(i, 20);
string strSaveFile = "SLT_Recognition_" + strQuarter;
workbook.Save(strSaveFile, FileFormatType.Default, SaveType.OpenInBrowser, this.Response);
}
}
catch (Exception err)
{
lblError.Text = "Error: " + err.Message;
lblError.Visible = true;
}