Click here to Skip to main content
15,910,277 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

in my application(ASP.NET,C#.NET), report comes in excel format. In one workbook, two sheets are there, in that one sheet is coping from another work book...
locally it is working fine, last day i have deployed my application in IIS, from there i have taken the report, in that workbook one sheet it is showing...which is originally created, another sheet(which is copied from another workbook) is not coming...not copied. Is there any problem with IIS configuration(I have done normal configuration). or in code? Please help me.

Thanks in advance...
Regards
murty
Posted

This will be a code problem. What are you using to generate the Excel report?
 
Share this answer
 
actually i have a parent file, in that one sheet is there with formats.
and another excel is required dynamically.(that is creating using XML)
Please see the below steps
Step 1: Creation of file in backup folder....
C#
string fileName="QA Report Day Ending " + DateTime.Now.Day.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Year.ToString() +  ".xls";
            string fName = Server.MapPath(@"Backup\") + fileName;
            string newFileName = fName;
            string oldFileName = Server.MapPath(@"Template\ParentFile.xls");
            File.Copy(oldFileName, newFileName, true);


Step 2: Creating XML format
XML
const string startExcelXML = "<xml version=\"\">\r\n<Workbook " +
          "xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\r\n" +
          " xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n " +
          "xmlns:x=\"urn:schemas-    microsoft-com:office:" +
          "excel\"\r\n xmlns:ss=\"urn:schemas-microsoft-com:" +
          "office:spreadsheet\">\r\n <Styles>\r\n " +
          "<Style ss:ID=\"Default\" ss:Name=\"Normal\">\r\n " +
          "<Alignment ss:Vertical=\"Bottom\"/>\r\n <Borders/>" +
          "\r\n <Font/>\r\n <Interior/>\r\n <NumberFormat/>" +
          "\r\n <Protection/>\r\n </Style>\r\n " 

MIDL
const string endExcelXML = "</Workbook></xml >";
       myHtml.Append(startExcelXML);
       myHtml.Append("<ss:Worksheet ss:Name=\"Detail QA Report\">");
       myHtml.Append("<ss:Table>");
       myHtml.Append("<ss:Column ss:Width='100'/>");
       myHtml.Append("<ss:Column ss:Width='150'/>");
       myHtml.Append("<ss:Column ss:Width='100'/>");

XML
myHtml.Append("<ss:Cell ss:StyleID=\"s41\">" +
                                       "<ss:Data ss:Type=\"String\">");
                        myHtml.Append("This is the First Row");
                        myHtml.Append("</ss:Data></ss:Cell>");

myHtml.Append("</ss:Table>");
myHtml.Append("");
myHtml.Append(" </ss:Worksheet>");

Step 3: for copied work sheet

app = new Application();
app.Visible = false;
workbook = app.Workbooks.Open(newFileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
baseWorkBook = app.Workbooks.Open(originalFileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Worksheet sheetSummary = new Worksheet();
baseWorkBook.Worksheets.Copy(workbook.Worksheets[1],Type.Missing);
baseWorkBook.Save();
Sheets xlSheets = workbook.Sheets as Sheets;
sheetSummary = (Worksheet)xlSheets[1];
sheetSummary.Cells[12, 2] = "QA Report Day Ending: "+ txtEndDate.Text.ToString();
MIDL
workbook.Save();
            workbook.Close(false, Type.Missing, Type.Missing);
            baseWorkBook.Save();
            baseWorkBook.Close(false, Type.Missing, Type.Missing);
            app.Quit();



This is what i have done,it is working on local system perfectly...I hope,in the IIS the workbook is not opening or not copying the worksheet...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900