Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
| Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 8th, 2006, 06:34 AM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?
Reply With Quote


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 workbook name qualifier AveryB Excel VBA 1 December 17th, 2007 10:41 PM
XPATH Help, Please- Excel XML Workbook jftaylor BOOK: XSLT Programmer's Reference, 2nd Edition 2 September 28th, 2006 08:47 PM
Import Excel data into a workbook Derek_05 Excel VBA 5 May 31st, 2006 02:02 PM
Closing Excel Workbook rekha_jsr Excel VBA 0 July 9th, 2005 02:40 AM
Saving Excel workbook with new filename tsegal20 Excel VBA 1 May 21st, 2004 01:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.