C# Excel Exportasfixedformat Pdf

Posted by admin- in Home -14/10/17

VSTO Excel and Word Add In CIntroduction. The main purpose of this article is to explain how to create simple Excel and Microsoft Word Add Ins using Visual Studio Tools for Office VSTO. VSTO is available as an add in tool with Microsoft Visual Studio. Using Visual Studio we can develop our own custom controls for Office tools like Excel, Word and and so on. In my demo program I have used Visual Studio 2. Office 2. 00. 7. This article explains a few basic things to create our own Custom Add Ins for Excel and Word as follows. Excel Add Ins. Add text to any Excel selected active Excel cell. Add an image to Excel from our Custom Control. Load data from a database and display the search result data in Excel. Word Add Ins. Export Word to PDF. Add Image to Word Document. Add Table to Word document. Code part. Creating Excel Add Ins. In my example I have used Visual Studio 2. ExcelExcelSheetSheetPDF Excel. In this article you will learn about VSTO Excel and Word AddIns C. C VB. NET ASP. NETCCLIJava C VB. NET Re4 ExcelPDF. Office 2. 00. 7. To create our own Custom Control Add Ins for Excel. Step 1. Create a new project and select Office 2. Excel Add. In as in the following Image. Select your Project Folder and enter your Project Name. Step 2. Now we can see that the Excel This. C# Excel Exportasfixedformat Pdf To Doc' title='C# Excel Exportasfixedformat Pdf To Doc' />C# Excel Exportasfixedformat PdfAdd. In. Cs file has been created in our project folder and we can find two default methods in this class as in the following image. This. Add. InStartup In this event we can display our own custom Control Add Ins to Excel. We can see the details in the code part. C Excel Exportasfixedformat Pdf ConverterStep 3. Add a new User. Control to your project to create your own Custom Excel Control Add In. Right click your project Click Add New Item Add User Control and Name the control as you wish. Add all your Controls and design your user control depending on your requirement. In my example, I am performing 3 types of actions in User Controls. Add Text In this button click event I will insert the text from the Text box to the Active Selected Excel Cell. Using Globals. This. Add. In. Application. Active. Cell we can get the current active Excel cell. We store the result in an Excel range and now using the range, value and color we can set our own text and colors to the active Excel Cell. Add. TextClickobject sender, Event. Args e        Excel. Range obj. Range  Globals. This. Add. In. Application. Active. Cell      obj. Range. Interior. Color  Color. Pink       obj. Range. Borders. Color  Color. Red      obj. Range. Borders. Line. Style  Excel. Xl. Line. Style. xl. Continuous      obj. Range. Value  txt. Active. Cell. Text. Text         obj. Range. Columns. Auto. Fit     Add Image using the Open File Dialog we can select our own image that needs to be added to the Excel file. Using the Excel. Shape we can add our selected image to the Excel file. Add. ImageClickobject sender, Event. Args e                        Open. File. Dialog dlg  new Open. File. Dialog              dlg. File. Name                dlg. Default. Ext  bmp              dlg. Validate. Names  true                dlg. Filter  Bitmap Image . Gif Image . gifJPEG Image . Png Image . png Show. Dialog  System. Windows. Forms. Dialog. Result. OK                                  Bitmap d. Img  new Bitmapdlg. File. Name                    Excel. Shape Iamge. Add  Globals. This. Add. In. Application. Active. Sheet. Shapes. Add. Picturedlg. File. Name,            Microsoft. Office. Core. Mso. Tri. State. mso. False,            Microsoft. Office. Core. Mso. Tri. State. mso. CTrue,            2. Img. Width, d. Img. Height                            System. Windows. Forms. Clipboard. Clear                   Search and bind Db Data to Excel Now we can create our own Custom Search control to be used in Excel to search our data from the database and bind the result to the Excel file. Creating the table    CREATE TABLE dbo. Item. Masters  ItemCode varchar2. NOT NULL,  ItemName varchar1. NOT NULL      INSERT INTO Item. Masters ItemCode,ItemName  VALUES Item. Coke    INSERT INTO Item. Masters ItemCode,ItemName  VALUES Item. Coffee    INSERT INTO Item. Masters ItemCode,ItemName  VALUES Item. Chiken Burger    INSERT INTO Item. Masters ItemCode,ItemName  VALUES Item. Potato Fry  In the button search click event we search for the data from the database and bind the result to an Excel cell using Globals. This. Add. In. Application. Active. Sheet. Cells. This will add the result to the active Excel sheet. SearchClickobject sender, Event. Args e        try                System. Data. Data. Table dt  new System. Data. Data. Table            String Connection. String  Data SourceYOURDATASOURCE Initial CatalogYOURDATABASENAME User id  UID passwordpassword          Sql. Connection con  new Sql. ConnectionConnection. String          String Query   Select ItemCode,ItemName FROM Item. Masters Where ItemName LIKE   txt. Item. Name. Text. Trim            Sql. Command cmd  new Sql. CommandQuery, con          cmd. Command. Type  System. Data. Command. Type. Text          System. Data. Sql. Client. Sql. Data. Adapter sda  new System. Web Service To File Scenario In Sap Pi Sheet. Data. Sql. Client. Sql. Data. Adaptercmd          sda. Filldt            if dt. Rows. Count lt  0                        return                      Globals. This. Add. In. Application. Active. Sheet. Cells. Clear. Contents            Globals. This. Add. In. Application. Active. Sheet. Cells1, 1. Value. 2  Item Code            Globals. This. Add. In. Application. Active. Sheet. Cells1, 2. Value. 2  Item Name            for int i  0 i lt  dt. Rows. Count  1 i                          Globals. This. Add. In. Application. Active. Sheet. Cellsi  2, 1. Value. 2  dt. Rowsi0. To. String                  Globals. This. Add. In. Application. Active. Sheet. Cellsi  2, 2. Value. 2  dt. Rowsi1. To. String                      catch Exception ex                Step 4. Now we have created our own User Control to be added to our Excel Add Ins. To add this user control to our Excel Add In as we have already seen that the Excel Addin class This. Add. In. Cs has start and stop events. Using the Office Custom. Taskpane we can add our usercontrol to Excel as an Add In as in the following. Microsoft. Office. Tools. Custom. Task. Pane custom. Pane    private void This. Add. InStartupobject sender, System. Event. Args e        Show. Shanu. Control    public void Show. Shanu. Control        var txt. Object  new Shanu. Excel. ADDIn      custom. Pane  this. Custom. Task. Panes. Addtxt. Object, Enter Text      custom. Pane. Width  txt. Object. Width      custom. Pane. Visible  true    Step 5. Run your program and now we can see our user control has been added in the Excel File as an Add In. Next we will see how to create Add Ins for Word Documents using a Ribbon Control. Creating Word Add Ins In my example I have used Visual Studio 2. Office 2. 00. 7. The following describes how to create our own Custom Control Add Ins for Word. Step 1. Create a new project and select Office 2. Word Add. In as in the following Image. Select your Project Folder and enter your Project Name. Step 2. Add a new Ribbon Control to your project to create your own Word Control Add In. Right click your project then click Add New Item Add Ribbon Control and name the control as you wish. Add all your controls and design your user control depending on your requirements. By default in our Ribbon Control we can see a Ribbon. Group. We can add all our controls to the Ribbon Group.