How to create excel file with multiple sheets in asp.net 2.0 c#

Hi there, I would like to create an excel file with multiple sheets in

Page 1 of 1

1 Replies - 14197 Views - Last Post: 23 November 2007 - 06:13 AM Rate Topic: -----

#1 anhnguyen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-October 07

How to create excel file with multiple sheets in asp.net 2.0 c#

Post icon  Posted 23 November 2007 - 02:38 AM

With this code below just allow me to create 2 file excel and each file has 1 report spreadsheet. However, I try to write 2 report into an excel file with 2 spreadsheet in this excel file. Could any one help me to solve this issue? Many thanks for this help.

/* First the Finance report */
/* Set the BusinessName */
PMOparameters[0].Value = validValue.Value;
PMOexecService.SetExecutionParameters(PMOparameters, "en-us");

// OK. Now render it!
string extension;
string mimeType;
string encoding;
Warning[] warnings = null;
string[] streamIDs = null;
byte[] PMOresult = PMOexecService.Render(
				"EXCEL",																	   "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>",
				out extension,
				out encoding,
				out mimeType,
				out warnings,
				out streamIDs);

// Write out the result.			
FileStream stream = File.Create(ReportsDir + @"\XLS\PMO" + validValue.Value + @".xls", PMOresult.Length);
stream.Write(PMOresult, 0, PMOresult.Length);
stream.Close();



Now the summary report
SummaryParameters[0].Value = validValue.Value;
SummaryExecService.SetExecutionParameters(SummaryParameters, "en-us");

Byte[] SummaryResult = SummaryExecService.Render(
																				"EXCEL",																						 "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>",
					out extension,
					out encoding,
					out mimeType,
					out warnings,
					out streamIDs);

stream = File.Create(ReportsDir + @"\XLS\SUMMARY" + validValue.Value + @".xls", SummaryResult.Length);
stream.Write(SummaryResult, 0, SummaryResult.Length);
stream.Close();



Mod Edit: Please use code tags for your code like so ==> :code:

This post has been edited by PsychoCoder: 29 November 2007 - 11:30 PM


Is This A Good Question/Topic? 0
  • +

Replies To: How to create excel file with multiple sheets in asp.net 2.0 c#

#2 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5805
  • View blog
  • Posts: 12,643
  • Joined: 16-October 07

Re: How to create excel file with multiple sheets in asp.net 2.0 c#

Posted 23 November 2007 - 06:13 AM

The real work is being done in PMOexecService? Without knowing that service, it quite impossible to answer the question. Curiously, a google on it reveals one page; this one.

It is possible to take an existing Excel sheet, save it to XML, and then reverse engineer it. All the confusing bits are layout and framework, the actual cells of data are not that complex. You can use an XmlTextWriter to make the file. it's probably not that straight forward, but it works.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1