I have created an existing excel with two worksheet. For my first worksheet it consist of data and I would like to add another data into same excel but second worksheet. Can I know why my code doesn't work?
public byte[] ExportToExcel()
{
Warning[] warnings = null;
string[] streamids = null;
string mimeType = null;
string encoding = null;
string extension = null;
byte[] content;
content = this.ReportViewer.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamids, out warnings);
return content;
}
ReportContent = ExportToExcel();
var path = ScheduledService.gstrReportPath;
var fullpath = Path.Combine(path, "ServerReport" + "_" + "_" + DateTime.Now.ToString("yyMMdd") + ".xls");
bool exists = System.IO.Directory.Exists(path);
if (!exists)
System.IO.Directory.CreateDirectory(path);
//Problem --------------------------------------------------------------------
FileStream file = File.Open(fullpath, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
file.Write(ReportContent, 0, ReportContent.Length);
file.Flush();
file.Close();