- #EXCEL NOT ENOUGH MEMORY OR DISK SPACE ERROR CODE#
- #EXCEL NOT ENOUGH MEMORY OR DISK SPACE ERROR WINDOWS#
Mail merge template document with DataTable. var document = DocumentModel.Load(Path.Combine(Request.PhysicalApplicationPath, " TemplateDocument.docx"), LoadOptions.DocxDefault)
Load a template document from application's root directory. New DataColumn( " Surname", typeof( string)) New DataColumn( " Name", typeof( string)), var dataTable = new DataTable( " People") You don't have to do this if you already have a DataTable instance. Define DataTable with two columns: 'Name' and 'Surname', and fill it with some data.
#EXCEL NOT ENOUGH MEMORY OR DISK SPACE ERROR CODE#
, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing) Ĭan you please help me for resolving such errors.Ĭopy Code // Use the component in free mode.ĬomponentInfo.SetLicense( " FREE-LIMITED-KEY")
The very first error regarding "Insufficient memory space" is occured on following asp.net line of code:ĭocument objWordDoc = (ref objFilePath, ref oMissing, ref oMissing, ref oMissing, ref oMissing "The process cannot access the file 'D:\inetpub\ApplicationClass objWord = new AppliationClass() If(File.Exists("path of doc file as shown in following exception."))įile.Copy("source path","destination path") After that our application throws following exception on the asp.net line of code: Save Document now.' exception I do the related setting as given into this article. Do let me know if your require any information/queries on this article. Hope this article will help you to work on MS Word or MS Excel from ASP.NET. Only impersonating the user in web.config to this application is enough, no need to configure Microsoft Word Component under component services ( Dcomcnfg.exe).
#EXCEL NOT ENOUGH MEMORY OR DISK SPACE ERROR WINDOWS#
This code is evaluated and tested on Windows XP, 2000 and also in Windows 2003. now u can successfully open the document from ASP.NET application. After adding this section in web.config run the application, To identity the user for this application -> Database connection information -> File Path for Word Template -> > Here we have to put the impersonation section This section sets the globalization settings of the application. So we need to impersonate the user who is launchingĬopy Code Allow all users -> GLOBALIZATION This is because of high level security in ASP.NET, The document now" while opening the word document "There is insufficient memory or disk space.save Response.Redirect(str_ServerPath + " /SaveDetails.doc") If (objErr.LogErrorToDB( " Error while export to word ",Ex, " ")= true) " WordFile").ToString(),str_ServerPath,ds_WordDetails) Įrrorlog.ErrorLog objErr= new Errorlog.ErrorLog() Getting the WordFile Path from Web.config // Calling Creatword function and passing // all the required parameters * Fill and populate the DS_Worddetails dataset from the table in your database*/ // Instantiating object for VBDLL WordClass
Private DataSet ds_DBSearch = new DataSet( " Ds_Worddetails") * "Event for Export to word document"*/ private void btnExptoWord_Click( object sender,System.EventArgs e) OWord = Nothing End Try End Function End Class End Namespace ' Add this WordClassLib as a reference ' in your ASP.NET application Calling from ASP.NET (code behind as C#) ODoc.SaveAs(str_FilePath & " SaveDetails.doc") If Not IsNothing(dsPutDetails) Then If 0 Then If dsPutDetails.Tables( " Search_Result").Rows.Count > 0 ThenĭsPutDetails.Tables( " Search_Result").Rows( 0) Obj_FileDelete.DeleteFile(str_FilePath & " SaveDetails.doc")Įnd If ' We used to get error while executing ' the next line which is opening the word template If obj_FileDelete.FileExists(str_FilePath & " SaveDetails.doc") Then Obj_FileDelete = CreateObject( " Scripting.FileSystemObject") ' Return Type:Boolean Public Function CreateWord( ByVal str_FilePath As String, _īyVal dsPutDetails As DataSet) As Boolean Dim oWord As New .Applicationĭim oDoc As New .Document ' Function Name:Create Word ' Scope Public ' Parameters: ' 1.str_FilePath-Template.dot file path which ' resides in Web.config and taken dynamically ' 2.str_server_Path-URL of the Application ' 3.dsPutDetails-Dataset Which is populating values ' from different Tables and writing ' the contents in to word document. ' Purpose: This createword function is to open ' the Template.dot (Word Template) file and ' save this document as DetailDocument.doc then user will ' be redirected to the DetailDocument.doc page where ' the user can open or save the document in to their local machine. Copy Code Option Explicit Off Imports System.Data