Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Unable To Create Excel Sheet At Runtime In my Application.

Unable To Create Excel Sheet At Runtime In my Application.

Scheduled Pinned Locked Moved ASP.NET
helpcsharpdatabasevisual-studioperformance
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sanket Patil
    wrote on last edited by
    #1

    Hi All, I am developing a web application. In that I have a web page that imports the data from EXCEL SHEET To Database. While doing this I have set some validation over the EXCEL Data. If the data is incorrect i need to write it in a new excel file which is created at run time. I have written the code to create new excel file with some data. But While Creating The Excel File I am Getting an error which i am unable to solve. So, Please Help me to solve my problem. I am using VS 2008 with c#. The Error is : Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. • To make more memory available, close workbooks or programs you no longer need. • To free disk space, delete files you no longer need from the disk you are saving to. The Code I have Written is :

    Excel.Application WRExcel = null;
    Excel.Workbooks WRwbs = null;

            Excel.\_Workbook WRwb = null;
            Excel.Sheets WRss = null;
    
            Excel.\_Worksheet WRws = null;
            object objOpt = System.Reflection.Missing.Value;
    
            if (System.IO.File.Exists("C:\\\\Excel1.xls"))
            {
                //Delete The Existing Excel Sheet
                System.IO.File.Delete("C:\\\\Excel1.xls");
            }
            //create Excel spreadsheet
    
            WRExcel = new Excel.Application();
    
            WRwb = WRExcel.Workbooks.Add(objOpt); // **My Error Occurs Here**
    
            WRss = (Excel.Sheets)WRwb.Worksheets;
    
            WRws = (Excel.\_Worksheet)(WRss.get\_Item(1));
    
            //create Excel column headings
    
            WRws.Cells\[1, 1\] = "Part Number.";
    
            WRws.Cells\[1, 2\] = "Kit Part.";
    
            WRws.Cells\[1, 3\] = "Description";
    
            WRws.Cells\[1, 4\] = "Reason For Reject";
    
    
            WRws.Cells\[2, 1\] = RowNo.Trim();
    
            WRws.Cells\[2, 2\] = ColumnNo.Trim();
    
            WRws.Cells\[2, 3\] = ErrorMsg.Trim();
    
            WRws.Cells\[2, 4\] = Filename;
            
            //save workbook
    
            WRwb.SaveAs("C:\\\\Excel1.xls", objOpt, objOpt, objOpt, objOpt, Opt,                 Excel.XlSaveAsAccessMode.xlNoChange, objOpt, objOpt, objOpt, objOpt, objOpt);
    
            //close workbook
    
            WRwbs.Close();
    

    Please Help me to Solve My Problem. Thanks & Regards Sanket Patil

    .

    P 1 Reply Last reply
    0
    • S Sanket Patil

      Hi All, I am developing a web application. In that I have a web page that imports the data from EXCEL SHEET To Database. While doing this I have set some validation over the EXCEL Data. If the data is incorrect i need to write it in a new excel file which is created at run time. I have written the code to create new excel file with some data. But While Creating The Excel File I am Getting an error which i am unable to solve. So, Please Help me to solve my problem. I am using VS 2008 with c#. The Error is : Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. • To make more memory available, close workbooks or programs you no longer need. • To free disk space, delete files you no longer need from the disk you are saving to. The Code I have Written is :

      Excel.Application WRExcel = null;
      Excel.Workbooks WRwbs = null;

              Excel.\_Workbook WRwb = null;
              Excel.Sheets WRss = null;
      
              Excel.\_Worksheet WRws = null;
              object objOpt = System.Reflection.Missing.Value;
      
              if (System.IO.File.Exists("C:\\\\Excel1.xls"))
              {
                  //Delete The Existing Excel Sheet
                  System.IO.File.Delete("C:\\\\Excel1.xls");
              }
              //create Excel spreadsheet
      
              WRExcel = new Excel.Application();
      
              WRwb = WRExcel.Workbooks.Add(objOpt); // **My Error Occurs Here**
      
              WRss = (Excel.Sheets)WRwb.Worksheets;
      
              WRws = (Excel.\_Worksheet)(WRss.get\_Item(1));
      
              //create Excel column headings
      
              WRws.Cells\[1, 1\] = "Part Number.";
      
              WRws.Cells\[1, 2\] = "Kit Part.";
      
              WRws.Cells\[1, 3\] = "Description";
      
              WRws.Cells\[1, 4\] = "Reason For Reject";
      
      
              WRws.Cells\[2, 1\] = RowNo.Trim();
      
              WRws.Cells\[2, 2\] = ColumnNo.Trim();
      
              WRws.Cells\[2, 3\] = ErrorMsg.Trim();
      
              WRws.Cells\[2, 4\] = Filename;
              
              //save workbook
      
              WRwb.SaveAs("C:\\\\Excel1.xls", objOpt, objOpt, objOpt, objOpt, Opt,                 Excel.XlSaveAsAccessMode.xlNoChange, objOpt, objOpt, objOpt, objOpt, objOpt);
      
              //close workbook
      
              WRwbs.Close();
      

      Please Help me to Solve My Problem. Thanks & Regards Sanket Patil

      .

      P Offline
      P Offline
      Prasanta_Prince
      wrote on last edited by
      #2

      http://forums.asp.net/t/1038105.aspx/1[^] Creating a formatted MS-Excel sheet using ASP[^] You can have a look on these.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups