Enterprise Services Integrationhttp://forums.asp.net/46.aspx/1?Enterprise+Services+IntegrationIntegrating Enterprise Services including Office, OWC, BizTalk, MSMQ, COM+, etc.Tue, 14 May 2013 11:32:40 -0400urn:uuid:00000000-0000-0000-0000-000000000046urn:uuid:00000000-0000-0000-0000-000003912833http://forums.asp.net/p/1567166/3912833.aspx/1?Using+ASP+NET+to+create+a+word+document+to+diskUsing ASP.NET to create a word document to disk <p>Hi all,<br> <br> I am building an application that I want to do the following in its simple form.<br> <br> <br> &nbsp;1. Website loads up and there is a button that says create word document.<br> &nbsp;2. Click the button and the word document is created and stored on the hard drive in the web application folder.<br> <br> <br> I found some code on the net that will generate a word document but when you click the button and run the code it opens a prompt box asking you where to save the file. I do not want to be prompted but to have it write the file to disk automatically. I have done this with text files before. Of course later on i can set all these values as to where the file should be saved in the web.config file. <br> <br> <br> Here is the sample code that prompts you where to save the file. <br> <br> </p> <pre class="prettyprint">protected void btnGenerateDocument_Click(object sender, EventArgs e) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Charset = &quot;&quot;; HttpContext.Current.Response.ContentType = &quot;application/msword&quot;; string strFileName = &quot;GenerateDocument&quot; &#43; &quot;.doc&quot;; HttpContext.Current.Response.AddHeader(&quot;Content-Disposition&quot;, &quot;inline;filename=&quot; &#43; strFileName); StringBuilder strHTMLContent = new StringBuilder(); strHTMLContent.Append(&quot; &lt;h1 title='Heading' align='Center' style='font-family:verdana;font-size:80%;color:black'&gt;&lt;u&gt;Document Heading&lt;/u&gt; &lt;/h1&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;br&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;table align='Center'&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;tr&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;td style='width: 100px;background:#99CC00'&gt;&lt;b&gt;Column 1&lt;/b&gt;&lt;/td&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;td style='width: 100px;background:#99CC00'&gt;&lt;b&gt;Column 2&lt;/b&gt;&lt;/td&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;td style='width: 100px;background:#99CC00'&gt;&lt;b&gt;Column 3&lt;/b&gt;&lt;/td&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;/tr&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;tr&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;td style='width: 100px'&gt;a&lt;/td&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;td style='width: 100px'&gt;b&lt;/td&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;td style='width: 100px'&gt;c&lt;/td&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;/tr&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;tr&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;td style='width: 100px'&gt;d&lt;/td&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;td style='width: 100px'&gt;e&lt;/td&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;td style='width: 100px'&gt;f&lt;/td&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;/tr&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;/table&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;br&gt;&lt;br&gt;&quot;.ToString()); strHTMLContent.Append(&quot;&lt;p align='Center'&gt; Note : This is dynamically generated word document &lt;/p&gt;&quot;.ToString()); HttpContext.Current.Response.Write(strHTMLContent); HttpContext.Current.Response.Write (strHTMLContent); HttpContext.Current.Response.End(); HttpContext.Current.Response.Flush(); }</pre> <p><br> <br> <br> I am basically going to eventually pull a record from a database and then using the source from a word document in the code behind and place those fields in there and generate the document. This document would then be in a folder where peopel can reach them and open when they wish to.<br> </p> 2010-06-09T15:04:32-04:002010-06-09T15:04:32.313-04:00urn:uuid:00000000-0000-0000-0000-000005393872http://forums.asp.net/p/1906026/5393872.aspx/1?Could+not+load+file+or+assembly+office+Version+14+0+0+0Could not load file or assembly 'office, Version=14.0.0.0 <p>Hello,</p> <p>I have&nbsp;an ASP.NET application (created using VS 2012) that is creating Excel files. I've set a refernce to Microsoft.Office.Interop.Excel.dll and&nbsp;it works fine on my PC. However, when I publish it to the server, it doesn't work:</p> <p><i>Could not load file or assembly 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.</i></p> <p>I've installed the <span style="font-family:'Calibri','sans-serif'; font-size:11pt"> Visual Studio 2010 Tools for Office Runtime </span>from here:</p> <p><a href="http://www.microsoft.com/en-us/download/details.aspx?id=35594">http://www.microsoft.com/en-us/download/details.aspx?id=35594</a></p> <p>Yet it still giving me the same error. What could be the problem?</p> <p>Thank you.</p> 2013-05-14T19:43:06-04:002013-05-14T19:43:06.25-04:00urn:uuid:00000000-0000-0000-0000-000005373973http://forums.asp.net/p/1901407/5373973.aspx/1?Cannot+create+ActiveX+component+Excel+2010+issueCannot create ActiveX component - Excel 2010 issue <p>Hello everyone,</p> <p>We have an application using &quot;excel dcom&quot;, and it was working fine (In dcomcnfg, I configured appropriate rights). But from today, i have the error &quot;<span>Cannot create ActiveX component.&quot; . I'm using Windows Server 2008 R2 x64 with Excel 2010 x64.</span></p> <p><span>I tried to uninstall, then install excel, I also rebooted the server, check the rights , set dcom rights to default, and change them to the right one (I need that IIS_IUSRS and IUSR are able to execute), I also changed to interactive to launching users (I have an other error &quot;&nbsp;microsoft excel cannot open or save any more documents because there is not enough available memory&quot;)&nbsp;</span></p> <p><span>I checked the process, when I launch the command on the application, the excel process is stared, but i still have the &quot;Cannot create ActiveX component&quot;</span></p> <p>So i'm now a little bit desperate :( So i'm requesting help here&nbsp;</p> <p></p> <p>Thanks in advance</p> 2013-04-24T15:52:11-04:002013-04-24T15:52:11.22-04:00urn:uuid:00000000-0000-0000-0000-000005393302http://forums.asp.net/p/1905891/5393302.aspx/1?how+to+find+the+word+document+is+readonly+or+not+how to find the word document is readonly or not? <p>&nbsp;</p> <p><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt">Hi,</span></p> <p><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt">How to find out the given word document is read-only or not using c#.</span></p> <p><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt">I am not talking about the read-only property of the (right click the document and you can enable or disable the read only checkbox) this one. i am talking about the read-only property, that while creating the word document you can make it as read only protected and now i want to access that one.</span></p> <p><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt">Please let me know if anybody knows about it.</span></p> <p><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt"><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt">but i tried the following</span></span></p> <p><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt"><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt"><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt"><span class="typ">FileInfo</span><span class="pln"> info </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">FileInfo</span><span class="pun">(</span><span class="pln">path</span><span class="pun">);</span><span class="pln"><br> info</span><span class="pun">.</span><span class="typ">IsReadOnly</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln"><br> </span><span class="typ">StreamWriter</span><span class="pln"> writer </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">StreamWriter</span><span class="pun">(</span><span class="pln">path</span><span class="pun">);</span><span class="pln"><br> writer</span><span class="pun">.</span><span class="typ">WriteLine</span><span class="pun">(</span><span class="str">&quot;This is an example.&quot;</span><span class="pun">);</span><span class="pln"><br> writer</span><span class="pun">.</span><span class="typ">Close</span><span class="pun">();</span><span class="pln"><br> info</span><span class="pun">.</span><span class="typ">IsReadOnly</span><span class="pun">=</span><span class="kwd">true</span><span class="pun">;</span></span></span></span></p> <p><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt"><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt"><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt"><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt"><span class="pun">but it did not worked.</span></span></span></span></span></p> <p><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt">Thanks,</span></p> <p><span style="font-family:'Segoe UI','sans-serif'; color:black; font-size:10pt">Burepalli V S Rao.</span></p> 2013-05-14T09:57:56-04:002013-05-14T09:57:56.3-04:00urn:uuid:00000000-0000-0000-0000-000005392141http://forums.asp.net/p/1905599/5392141.aspx/1?Microsoft+office+interop+excel+while+exporting+to+excel+store+number+as+text+Microsoft.office.interop.excel, while exporting to excel store number as text ? <h3 class="r">Microsoft.office.interop.excel, while exporting to excel , how can i store a number like &quot;0015200&quot; as text in excel cell</h3> 2013-05-13T09:40:11-04:002013-05-13T09:40:11.02-04:00urn:uuid:00000000-0000-0000-0000-000005386003http://forums.asp.net/p/1904195/5386003.aspx/1?Get+HTML+text+from+database+and+out+into+MS+Word+C+Get HTML text from database and out into MS Word C# <p>I have a table in a database that contains a field, which has text formatted in HTML in it.&nbsp; For example, &lt;p&gt;This is a &lt;b&gt;test.&lt;/b&gt;&lt;/p&gt;</p> <p>I want to insert this text into MS word.&nbsp; I'm not using the HTMLformat... way.&nbsp; I am using the Microsoft.Office.Interop.Word._Application oWord; way.&nbsp; Is there a way to set the .Text property to equal the text?&nbsp; So it pulls out of the database as:</p> <p>&lt;p&gt;This is a &lt;b&gt;test.&lt;/b&gt;&lt;/p&gt; but in MS word should be inserted as:</p> <p>This is a <strong>test</strong>.</p> <p><strong>http://forums.asp.net/t/1224223.aspx/1</strong></p> <p>I want code similar to this:</p> <p>object TemplatefileName = Server.MapPath(&quot;Template&quot;) &#43; &quot;<a>\\High.doc</a>&quot;;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object novalue = System.Reflection.Missing.Value;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Word.Table oTable; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Word.ApplicationClass objWord = new Word.ApplicationClass();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Word.Document objWordDoc = objWord.Documents.Add(ref TemplatefileName, ref novalue, ref novalue, ref novalue);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objWordDoc.Activate();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objWordDoc.Application.Visible = true;</p> <p>Not this:</p> <pre class="prettyprint">Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter) Dim strBody As New System.Text.StringBuilder(&quot;&quot;) strBody.Append(&quot;&amp;lt;html &quot; &amp; _ &quot;xmlns:o='urn:schemas-microsoft-com:office:office' &quot; &amp; _ &quot;xmlns:w='urn:schemas-microsoft-com:office:word'&quot; &amp; _ &quot;xmlns='http://www.w3.org/TR/REC-html40'&amp;gt;&quot; &amp; _ &quot;&lt;head&gt;&lt;title&gt;&lt;/title&gt;&quot;) 'The setting specifies document's view after it is downloaded as Print Layout 'instead of the default Web Layout. For the Header &amp; Footer to be visible, 'this mode is required. strBody.Append(&quot;&lt;!--[if gte mso 9]&gt;&quot; &amp; _ &quot;&lt;xml&gt;&quot; &amp; _ &quot;&lt;w:WordDocument&gt;&quot; &amp; _ &quot;&lt;w:View&gt;Print&lt;/w:View&gt;&quot; &amp; _ &quot;&lt;w:Zoom&gt;90&lt;/w:Zoom&gt;&quot; &amp; _ &quot;&lt;w:DoNotOptimizeForBrowser/&gt;&quot; &amp; _ &quot;&lt;/w:WordDocument&gt;&quot; &amp; _ &quot;&lt;/xml&gt;&quot; &amp; _ &quot;&lt;![endif]--&gt;&quot;) 'we can tweak the MsoFooter class that is referenced by the footer, as required strBody.Append(&quot;&lt;style&gt;&quot; &amp; _ &quot;&lt;!-- /* Style Definitions */&quot; &amp; _ &quot;p.MsoFooter, li.MsoFooter, div.MsoFooter&quot; &amp; _ &quot;{margin:0in;&quot; &amp; _ &quot;margin-bottom:.0001pt;&quot; &amp; _ &quot;mso-pagination:widow-orphan;&quot; &amp; _ &quot;tab-stops:center 3.0in right 6.0in;&quot; &amp; _ &quot;font-size:12.0pt;}&quot; &amp; _ &quot;p.MsoHeader, li.MsoHeader, div.MsoHeader&quot; &amp; _ &quot;{margin:0in;&quot; &amp; _ &quot;margin-bottom:.0001pt;&quot; &amp; _ &quot;mso-pagination:widow-orphan;&quot; &amp; _ &quot;tab-stops:center 3.0in right 6.0in;&quot; &amp; _ &quot;font-size:12.0pt;}&quot;)</pre> 2013-05-06T18:37:42-04:002013-05-06T18:37:42.927-04:00urn:uuid:00000000-0000-0000-0000-000005378058http://forums.asp.net/p/1902382/5378058.aspx/1?Open+XML+SDK+Mail+merge+into+one+documentOpen XML SDK Mail merge into one document <p>Hi,</p> <p>I need to be able to create a mail merge and rather than creating 100 documents it should only create one word document with all the mail merges in it... does any one have any samples on this? any resource material.. (c#.. mvc)</p> <p>I have found samples on how to create mail merges with multiple documents, but I am only looking for all the mail merges to be merged into one document, so it is easier for the user to just download this one document to print rather than print each one..</p> <p>thanks in advanced</p> <p></p> <p></p> 2013-04-29T06:17:23-04:002013-04-29T06:17:23.707-04:00urn:uuid:00000000-0000-0000-0000-000005363654http://forums.asp.net/p/1899001/5363654.aspx/1?Mail+mergeMail merge <p>Hi guys,</p> <p>I have a template letter in word.. I need to create a mail merge from a SQL database.. and then return the generated letters as one document to the user...</p> <p>I am using MVC 4</p> <p>any recomedations? any sample code? best practices?</p> <p>Thanks in advance</p> 2013-04-15T03:16:31-04:002013-04-15T03:16:31.24-04:00urn:uuid:00000000-0000-0000-0000-000005378926http://forums.asp.net/p/1902573/5378926.aspx/1?Event+1000+1026+ErrorsEvent 1000 & 1026 Errors <p>I &nbsp;have a windows command line application that retrieves information from a SQL database.&nbsp; This information is then used to populate a new Excel workbook and saves it as an xls file.&nbsp; The application works as specified from the command line.&nbsp; However, when I try executing the same application through an ASP.NET webpage on the web server, it executes part way and the Excel process becomes orphaned.</p> <p>The only&nbsp;information I have to go on&nbsp;from the event viewer are the following errors.</p> <p><strong>1st Error:</strong> (#1000 Application Error)</p> <p>Faulting application name: xl.exe, version: 1.0.0.0, time stamp: 0x5159c582</p> <p>Faulting module name: KERNELBASE.dll, version: 6.1.7601.17651, time stamp: 0x4e211319</p> <p>Exception code: 0xe0434352</p> <p>Fault offset: 0x0000b9bc</p> <p>Faulting process id: 0x5bc</p> <p>Faulting application start time: 0x01ce315fe8ce455b</p> <p>Faulting application path: D:\Inetpub\www\build\report\xl.exe</p> <p>Faulting module path: C:\Windows\syswow64\KERNELBASE.dll</p> <p>Report Id: 279d396c-9d53-11e2-863b-6ad9cec2af31</p> <p></p> <p><strong>2nd Error:</strong> (#1026 .NET Runtime)</p> <p>Application: xl.exe</p> <p>Framework Version: v4.0.30319</p> <p>Description: The process was terminated due to an unhandled exception.</p> <p>Exception Info: System.Runtime.InteropServices.COMException</p> <p>Stack:</p> <p>&nbsp;&nbsp; at System.RuntimeType.ForwardCallToInvokeMember(System.String, System.Reflection.BindingFlags, System.Object, Int32[], System.Runtime.Remoting.Proxies.MessageData ByRef)</p> <p>&nbsp;&nbsp; at Microsoft.Office.Interop.Excel.PageSetup.set_PaperSize(Microsoft.Office.Interop.Excel.XlPaperSize)</p> <p>&nbsp;&nbsp; at AdvOffice.AdvExcel.InitializeWorksheet(Microsoft.Office.Interop.Excel.Worksheet)</p> <p>&nbsp;&nbsp; at ExcelCheckList.ScoreSheet..ctor(Boolean, Boolean, System.String, Int32)</p> <p>&nbsp;&nbsp; at STP.Program.Main(System.String[])</p> <p>&nbsp;</p> <p>Please note that these errors do not appear when executing the same app from the command line.</p> <p>Any suggestions on how to suppress these errors so that my application can execute is much appreciated.</p> 2013-04-29T17:04:43-04:002013-04-29T17:04:43.89-04:00urn:uuid:00000000-0000-0000-0000-000005376309http://forums.asp.net/p/1901964/5376309.aspx/1?How+to+Set+Background+Image+in+wordHow to Set Background Image in word <p><span>Hi Anyone please me how to set&nbsp;Background Image in word .My problem is we are using Xslt &nbsp;and generating Word document But i need to set a background image for the douments.</span></p> <p><span>Below my detailed example ...</span></p> <p><span><a href="http://social.msdn.microsoft.com/Forums/en-US/worddev/thread/dbaa153b-6978-463c-b419-1fd55441446f/">http://social.msdn.microsoft.com/Forums/en-US/worddev/thread/dbaa153b-6978-463c-b419-1fd55441446f/</a></span></p> 2013-04-26T14:11:54-04:002013-04-26T14:11:54.227-04:00urn:uuid:00000000-0000-0000-0000-000005369357http://forums.asp.net/p/1900350/5369357.aspx/1?Word+Mail+Merge+With+Asp+NetWord Mail Merge With Asp .Net <p>Hi all,</p> <p>I need to develop more than 300 covering letter for my project. And it will be time consuming job. So i planned to design covering letter by easiest way. If i use crystal report, that may be risk to design and future alteration. I wish to do this by easiest way. How to use Word Mail Merge from asp .net? My idea is passing input to word mail merge from asp .net form and open that predesigned document with given input related data by clicking button. If any other concept exists,please refer me.</p> 2013-04-19T14:16:40-04:002013-04-19T14:16:40.503-04:00urn:uuid:00000000-0000-0000-0000-000005312170http://forums.asp.net/p/1884972/5312170.aspx/1?How+to+create+a+xlsx+in+asp+net+How to create a .xlsx in asp.net <p>I'm able to create .xls. I unable to create .xlsx file using asp.net. could you help someone on the same.</p> <p>thanks in advance.</p> 2013-02-23T18:41:09-05:002013-02-23T18:41:09.533-05:00urn:uuid:00000000-0000-0000-0000-000005364333http://forums.asp.net/p/1899154/5364333.aspx/1?Connecting+MQ+Client+channel+definition+table+CCDT+vs+HostChannel+and+QueueNameConnecting MQ Client channel definition table (CCDT ) vs HostChannel and QueueName <p>.Net Application connecting to IBM MQ Client channel definition table (CCDT ) vs HostChannel and QueueName.</p> <p>Thanks</p> 2013-04-15T13:42:16-04:002013-04-15T13:42:16.053-04:00urn:uuid:00000000-0000-0000-0000-000005373430http://forums.asp.net/p/1901287/5373430.aspx/1?how+to+send+email+from+Outlook+2007+using+System+Net+HttpWebRequesthow to send email from Outlook 2007 using System.Net.HttpWebRequest &lt;div class=&quot;body&quot;&gt; &lt;div&gt; <p>how to send email from Outlook 2007 using System.Net.HttpWebRequest in vb.net 2005</p> <p>Please help its urgent</p> <p>Thanks in Advance</p> &lt;/div&gt; &lt;/div&gt; 2013-04-24T08:57:11-04:002013-04-24T08:57:11.613-04:00urn:uuid:00000000-0000-0000-0000-000005370190http://forums.asp.net/p/1900536/5370190.aspx/1?PDF+to+Word+converter+in+VB+and+versa+PDF to Word converter in VB ( and versa) <p><br> Hello everyboy hope all is good,<br> <br> Im beginner in visual basic but i have little backgroud i hope every expert&nbsp;here help me with this<br> becasue im a IT administrator and i need this software really urgent,</p> <p>I need a software to convert from PDF -&gt;Word and Word -&gt; PDF &nbsp; not change the Extension<br> i know it's simple software to be made by searching in the internet,<br> i have tried some of them (codes) but all are just trying to change the Extension.</p> <p>i need your help guys, Need the codes to be work in Visual studio 2010 Ultimate,<br> <br> have a nice day,</p> <p>Ahmed.</p> <p></p> 2013-04-20T18:00:49-04:002013-04-20T18:00:49.983-04:00urn:uuid:00000000-0000-0000-0000-000004347256http://forums.asp.net/p/1664388/4347256.aspx/1?How+to+merge+Two+Different+Excel+sheets+How to merge Two Different Excel sheets? <p>Hi,</p> <p>How do i write a programme to merge Two different excel docs(Columns are different in two sheets) into one excel sheet?</p> <p>For instance, Excel1.xslx has a and b columns</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Excel2.xslx has c and d columns</p> <p>Now i want to combine those two excel documents and create excel 3 with a,b,c,d columns</p> 2011-03-17T23:58:44-04:002011-03-17T23:58:44.63-04:00urn:uuid:00000000-0000-0000-0000-000004107985http://forums.asp.net/p/1608753/4107985.aspx/1?Merging+Multiple+Excel+files+exports+from+Reporting+Services+Merging Multiple Excel files (exports from Reporting Services) <p>So we have Office 2007 on our system and I'm trying to use Excel Interop to take a number of Excel files, which are exports from Reporting Services, and combine them into one large workbook.&nbsp; I'm using the code below which works fine to get all the information from all the files into one workbook but the colors of things goes absolutely haywire.&nbsp; Anyone know why my colors are getting all out of wack?</p> <p><br> </p> <p>protected void MergeFiles(string destinationFile, string[] sourceFiles, string guid)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //1. Validate folder, &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //2. Instantiate excel object &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //3. Loop through the files &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //4. Add sheets &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //5. Save and enjoy! &nbsp;<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object missing = System.Reflection.Missing.Value; &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.Office.Interop.Excel.ApplicationClass ExcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass(); &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ExcelApp.Visible = false; &nbsp;<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Create destination object &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.Office.Interop.Excel.Workbook objBookDest = ExcelApp.Workbooks.Add(missing); &nbsp;<br> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (string filename in sourceFiles) &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (File.Exists(filename)) &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //create an object &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.Office.Interop.Excel.Workbook objBookSource = ExcelApp.Workbooks._Open &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (filename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); &nbsp;<br> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Browse through all files. &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (Microsoft.Office.Interop.Excel.Worksheet sheet in objBookSource.Worksheets) &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sheet.Copy(Type.Missing, objBookDest.Worksheets[objBookSource.Worksheets.Count]); &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objBookSource.Close(Type.Missing, Type.Missing, Type.Missing); &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objBookSource = null;&nbsp; &nbsp;<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objBookDest.SaveAs(destinationFile, Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel8, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objBookDest.Close(Type.Missing, Type.Missing, Type.Missing); &nbsp;<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objBookDest = null; &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ExcelApp = null; &nbsp;<br> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (System.Exception e) &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Catch &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> 2010-10-01T22:47:47-04:002010-10-01T22:47:47-04:00urn:uuid:00000000-0000-0000-0000-000004615450http://forums.asp.net/p/1724712/4615450.aspx/1?How+to+merge+two+excel+files+into+one+with+their+sheet+names+How to merge two excel files into one with their sheet names? <p>Hi,</p> <p>For merging of two excel sheet, I am using below code.</p> <p></p> <pre class="lang-cs prettyprint"><pre class="prettyprint">using System; using Excel = Microsoft.Office.Interop.Excel; using System.Reflection; namespace MergeWorkBooks { class Program { static void Main(string[] args) { Excel.Application app = new Excel.Application(); app.Visible = true; app.Workbooks.Add(&quot;&quot;); app.Workbooks.Add(@&quot;c:\MyWork\WorkBook1.xls&quot;); app.Workbooks.Add(@&quot;c:\MyWork\WorkBook2.xls&quot;); for (int i = 2; i &lt;= app.Workbooks.Count; i&#43;&#43;) { int count = app.Workbooks[i].Worksheets.Count; app.Workbooks[i].Activate(); for (int j=1; j &lt;= count; j&#43;&#43;) { Excel._Worksheet ws = (Excel._Worksheet)app.Workbooks[i].Worksheets[j]; ws.Select(Type.Missing); ws.Cells.Select(); Excel.Range sel = (Excel.Range)app.Selection; sel.Copy(Type.Missing); Excel._Worksheet sheet = (Excel._Worksheet)app.Workbooks[1].Worksheets.Add( Type.Missing, Type.Missing, Type.Missing, Type.Missing ); sheet.Paste(Type.Missing, Type.Missing); } } } } }</pre></pre> <p></p> <p>This code is working good for me for merging excel workbook. But at the time of merging I am not getting the excel sheet names. Here I need that when the excel is merging at the same time the sheet names should also go to the merged excel sheet. So please help me out on this. Its urgent. Thanks In Advance...</p></pre> 2011-09-27T11:38:32-04:002011-09-27T11:38:32.417-04:00urn:uuid:00000000-0000-0000-0000-000004150884http://forums.asp.net/p/1619175/4150884.aspx/1?Merge+two+different+excel+files+into+one+excel+file+in+c+Merge two different excel files into one excel file in c# <p>Hi;</p> <p>&nbsp;</p> <p>I simply want to merge&nbsp;two&nbsp;excel files into another&nbsp;excel file. I guess i&nbsp;should&nbsp;use Intertor for that but i don't know how to use it, never use it before. May anyone help please... Thanks!</p> 2010-11-02T07:58:08-04:002010-11-02T07:58:08.397-04:00urn:uuid:00000000-0000-0000-0000-000002983854http://forums.asp.net/p/1393088/2983854.aspx/1?How+to+merge+sheets+from+multiple+excel+files+into+one+xls+file+How to merge sheets from multiple excel files into one .xls file? <p>&nbsp;I have several excel spreadsheet fils, each of them contains multiple work sheets that may storing images or data.</p> <p>&nbsp;How could I merge all of these work sheets to just one .xls file and keep their original layout and style using asp.net? </p> <p>&nbsp;Thanks in advance. <br> </p> 2009-03-05T05:23:52-05:002009-03-05T05:23:52.197-05:00