We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.words.net is not opening the document in windows 2008 R2 with IE 8

Hi ,

I have developed a mail merge solution using Aspose.words.net 8.2.1 version ,its working in my local machine using windows xp with IE7 ,but when i deploy it in windows 2008 R2 with IE8 its not working,and it is not working in any of the server machine.Its working fine if i save the document.But its not working when i open the document in browser.The document is not opening in the browser in IE8,IE6 in windows 2008 R@ and windows 2003.

Here is my code for reference

string buname = GetBUNameForID(buid);

MSCRMService.BusinessEntity quonobe = Quote(QuoteID);

string quotenumber = Getquotenumber(quonobe);

Guid companyid = GetAccountID(quonobe);

string[] companyDetails = GetAccountNameForID(companyid);

string companyname = companyDetails[0];

string companymailid = companyDetails[1];

string companystate = companyDetails[2];

string tandc = GetTermsandConditions(companystate);

string quotedate = GetquoteDate(quonobe);

// Open an existing document.

string PATH = Server.MapPath(".");

Document doc = new Document(PATH + "\\SAMPLEQUOTE2.dotx");

// Document doc = new Document("E:\\Divya\\SAMPLEQUOTE2.dotx");

// Use DataTable as a data source.

MSCRMService.BusinessEntityCollection productbc = QuoteDetails();

DataTable Products = productregion(productbc);

//// The table name property should be set to match the name of the region defined in the document.

//Products.TableName = "Products";

//doc.MailMerge.ExecuteWithRegions(Products);

// Instead of using DataTable you can create a DataView for custom sort or filter and then mail merge.

DataView productDetailsView = new DataView(productregion(productbc));

productDetailsView.Sort = "ProductName ASC";

doc.MailMerge.ExecuteWithRegions(productDetailsView);

// Fill the fields in the document with user data.

doc.MailMerge.Execute(

new string[] { "Company", "UserFax", "UserFrom", "UserDept", "UserTelephone", "UserFax2", "UserEmail", "Business_Unit", "UserStreet1", "UserStreet2", "UserState", "UserPostCode", "Title", "QuoteID", "TermsandConditions", "QuoteDate" },

new object[] { companyname, companymailid, fullname, buname, phone, faxno, Email, buname, street1, street2, state, postalcode, title, quotenumber, tandc, quotedate });

// Send the document in Word format to the client browser.

//doc.Save(

//"PersonalizedLetter Out.doc", SaveFormat.Doc, SaveType.OpenInBrowser, Response);

doc.Save("Report Out.doc", SaveFormat.Doc, SaveType.OpenInApplication, Response);

//doc.Save("C:\\BPBitumen\\Document.OpenFromFile Out.doc");

The word is not opening the document in browser in IE8.what i need to do.

Hi ,

I have developed a mail merge solution using Aspose.words.net 8.2.1 version ,its working in my local machine using windows xp with IE7 ,but when i deploy it in windows 2008 R2 with IE8 its not working,and it is not working in any of the server machine.Its working fine if i save the document.But its not working when i open the document in browser.The document is not opening in the browser in IE8,IE6 in windows 2008 R@ and windows 2003.

Here is my code for reference

string buname = GetBUNameForID(buid);

MSCRMService.BusinessEntity quonobe = Quote(QuoteID);

string quotenumber = Getquotenumber(quonobe);

Guid companyid = GetAccountID(quonobe);

string[] companyDetails = GetAccountNameForID(companyid);

string companyname = companyDetails[0];

string companymailid = companyDetails[1];

string companystate = companyDetails[2];

string tandc = GetTermsandConditions(companystate);

string quotedate = GetquoteDate(quonobe);

// Open an existing document.

string PATH = Server.MapPath(".");

Document doc = new Document(PATH + "\\SAMPLEQUOTE2.dotx");

// Document doc = new Document("E:\\Divya\\SAMPLEQUOTE2.dotx");

// Use DataTable as a data source.

MSCRMService.BusinessEntityCollection productbc = QuoteDetails();

DataTable Products = productregion(productbc);

//// The table name property should be set to match the name of the region defined in the document.

//Products.TableName = "Products";

//doc.MailMerge.ExecuteWithRegions(Products);

// Instead of using DataTable you can create a DataView for custom sort or filter and then mail merge.

DataView productDetailsView = new DataView(productregion(productbc));

productDetailsView.Sort = "ProductName ASC";

doc.MailMerge.ExecuteWithRegions(productDetailsView);

// Fill the fields in the document with user data.

doc.MailMerge.Execute(

new string[] { "Company", "UserFax", "UserFrom", "UserDept", "UserTelephone", "UserFax2", "UserEmail", "Business_Unit", "UserStreet1", "UserStreet2", "UserState", "UserPostCode", "Title", "QuoteID", "TermsandConditions", "QuoteDate" },

new object[] { companyname, companymailid, fullname, buname, phone, faxno, Email, buname, street1, street2, state, postalcode, title, quotenumber, tandc, quotedate });

// Send the document in Word format to the client browser.

//doc.Save(

//"PersonalizedLetter Out.doc", SaveFormat.Doc, SaveType.OpenInBrowser, Response);

doc.Save("Report Out.doc", SaveFormat.Doc, SaveType.OpenInApplication, Response);

//doc.Save("C:\\BPBitumen\\Document.OpenFromFile Out.doc");

The word is not opening the document in browser in IE8.what i need to do.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. When you click “Open” button in Open/Save dialog, OS tries to open the file using the default application, which is used to open such kind of files. For DOC files this is MS Word. So if you try to open the file on machine where MS Word is not installed, you will probably see nothing.

Actually, the Save("out.doc", SaveFormat.Doc, SaveType.OpenInApplication, Response) method works like the following code.

Aspose.Words.Document doc = new Aspose.Words.Document();

Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);

builder.Write("Hello world!!!");

MemoryStream stream = new MemoryStream();

doc.Save(stream, SaveFormat.Doc);

Response.Clear();

//Specify the document type.

Response.ContentType = "application/msword";

//Other options:

//Response.ContentType = "text/plain"

//Response.ContentType = "text/html"

//Specify how the document is sent to the browser.

//Response.AddHeader("content-disposition","attachment; filename=MyDocument.doc");

//Another option could be:

Response.AddHeader("content-disposition", "inline; filename=MyDocument.doc");

//Get data bytes from the stream and send it to the response.

byte[] bytes = stream.GetBuffer();

Response.BinaryWrite(bytes);

Response.End();

So, you can try using this code for testing.

Best regards.

Thanks for your reply,i am using a word template and i have installed the ms word in my machine.can you please suggest me the code for using template in this sitautaion.

Thanks

Divya

Thanks for your reply,i am using a template document.Can you please give me the code for loading the template word document in this situation.

Thanks

Divya

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. As I can see you already use template in your code. Here is snippet of your code:

// Open an existing document.

string PATH = Server.MapPath(".");

Document doc = new Document(PATH + "\\SAMPLEQUOTE2.dotx");

I supposed the actual problem is that when you click “Open” button in open/save dialog in IE nothing happens. Please clarify what the actual problem is.

Best regards.

Thanks for your reply ,yes you are right in IE the document is not opening when i click open button.It displays nothing when i run in my server.Is there any issue with browser or with doc.save method which i had mentioned earlier in my code.

Thanks

Divya

Hi,

I used the document builder it is opening but how do i open my template document and how can i merge the fields using document builder.it is not given in the documentation.can you please send the code .

Thanks

Divya

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information.

1. I do not think that Aspose.Words causes the problem with opening a document in browser. Have you tried using code like the following for testing?

Response.Clear();

//Specify the document type.

Response.ContentType = "application/msword";

//Other options:

//Response.ContentType = "text/plain"

//Response.ContentType = "text/html"

//Specify how the document is sent to the browser.

//Response.AddHeader("content-disposition","attachment; filename=MyDocument.doc");

//Another option could be:

Response.AddHeader("content-disposition", "inline; filename=MyDocument.doc");

//Get data bytes from the stream and send it to the response.

byte[] bytes = File.ReadAllBytes("test.doc");

Response.BinaryWrite(bytes);

Response.End();

As you can see this code does not use Aspose.Words, it just reads a document and sends it into the client’s browser. If this code will cause the same problem, then the problem is somewhere on your side.

2. Regarding using template, you do not need to use DocumentBuidler to fill merge fields. You already use MailMerge approach to fill your template with data in your code. And this is correct approach. Please see the following link for more information:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/mail-merge-and-reporting.html

Best regards.