Display Excel Workbook in browser
Hi All,
I need to display an excel workbook which has 2 sheets in a browser.
The issue is after displaying the 1st sheet, i do not know what to char to output which indicates that the data should now be displayed on a new sheet. Below is the code.
void TSMF::DownloadData(RCLString filename)
{
cout << "Content-Type: application/vnd.ms- excel; filename=Statistics.xls\n";
cout << "Content-Disposition: attachment; filename=Statistics.xls\n";
cout << "\n";
BasicExcel excelWorkbook;
// Loads the excel workbook that i want to open or save
excelWorkbook.Load(filename);
size_t maxSheets = excelWorkbook.GetTotalWorkSheets();
for (size_t i=0; i<maxSheets; ++i)
{
// Pointer to the sheet
BasicExcelWorksheet* sheet = excelWorkbook.GetWorksheet(i);
if (sheet)
{
size_t maxRows = sheet->GetTotalRows();
size_t maxCols = sheet->GetTotalCols();
for (size_t r=0; r<maxRows; ++r)
{
for (size_t c=0; c<maxCols; ++c)
cout << *(sheet->Cell(r,c)) << "\t";
// "\t" is used so that the data read goes on a new cell
cout << endl;
}
}
/* here is where the issue is. as of now, im outputting "endl", so the next sheet data is being displayed on the same sheet with a blank line inserted in between */
cout << endl;
}
}
Could somebody please tell me how to go about this issue?
|