In this post I tried to explain about, how to work with the macro enabled excel sheet. Macro enabled excel use VBA (Visual Basic for Application) for functional purpose in excel sheets. This post is a part of my Retrieve data from excel file in code behind .
1. Import library into your application. I assign a name to that library for working easily.
2. Assign a values
3. Get the procedure name which use into your VBA code.
Macro name is the combined of component name and procedure name. So you must concatenate this ComponentName and procedureName which I used in this application.
4. Application.Run method help to update your changes in your application.
Thursday, September 22, 2011
Save your excel file as PDF document
In my previous post, Retrieve data from excel file in code behind,I told you about how to work with the excel file. Purpose of this post is, giving a knowledge about how to convert your excel file into PDF format .
For further details about Workbook.ExportAsFixedFormat Method.You can do same this for any other Microsoft Office document. If you have some problem while working this code, please install Add-in to your PC.
Labels:
c# .net
Thursday, September 15, 2011
Retrive data from excel file in code behind
There are two ways to implement this scenario.
i. create a OleDbConnection and work with like a Database
ii. using excel data library and get its functionality
I think second one is the better solution to doing this.
1. Import excel library into the class
I assign a library to simple word(Excel) for working easily
2. Create objects
3. Assign values
4. Assign values to object
In this case you can open all sheets in workbook, only doing is parsing a specific sheet number which you need to open. Further details you can access the Workbooks.Open Method
5. Get the data range in excel file and fill it to the ArrayList
6. Save your data in excel sheet
You can change rowNo & columnNo. This is the cell position which you want to save your data.
7. Close the application
8. Finlay you must release all the excel objects.
In this application I also release the xlWorkBook object and xlWorkSheet object.
i. create a OleDbConnection and work with like a Database
ii. using excel data library and get its functionality
I think second one is the better solution to doing this.
1. Import excel library into the class
I assign a library to simple word(Excel) for working easily
2. Create objects
3. Assign values
4. Assign values to object
In this case you can open all sheets in workbook, only doing is parsing a specific sheet number which you need to open. Further details you can access the Workbooks.Open Method
5. Get the data range in excel file and fill it to the ArrayList
6. Save your data in excel sheet
You can change rowNo & columnNo. This is the cell position which you want to save your data.
7. Close the application
8. Finlay you must release all the excel objects.
In this application I also release the xlWorkBook object and xlWorkSheet object.
Labels:
c# .net
Monday, September 12, 2011
Working with GridView in Code Behind
1. I add GridView into my .aspx page. My database table consist with four columns(Id, FirstName, LastName, DateCreated)
2. Bind your Grid
In this example I used Microsoft Enterprise Library. For further details you can access my previous post, Working with SqlServer using Microsoft Enterprise Library
3. You can add data while binding data in your grid. In this example I add a java script function to each row.
4. Allow to change your page index.
5. I add two command field (Edit & Delete) into the Grid. You can add any command fields into the Grid.
6. Allow to delete row data
2. Bind your Grid
In this example I used Microsoft Enterprise Library. For further details you can access my previous post, Working with SqlServer using Microsoft Enterprise Library
3. You can add data while binding data in your grid. In this example I add a java script function to each row.
4. Allow to change your page index.
5. I add two command field (Edit & Delete) into the Grid. You can add any command fields into the Grid.
6. Allow to delete row data
Labels:
asp .net
Subscribe to:
Posts (Atom)