Friday, July 16, 2010

Export data of Listview Control to excel file by using c#.net

Add the reference of the Microsoft Excel Object 12 reference into your project

then add the following code

Microsoft.Office.Interop.Excel.Application xla = new Microsoft.Office.Interop.Excel.Application();

xla.Visible = true;

Microsoft.Office.Interop.Excel.Workbook wb = xla.Workbooks.Add(Microsoft.Office.Interop.Excel.XlSheetType.xlWorksheet);

Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)xla.ActiveSheet;

int i = 1;

int j = 1;

foreach (ListViewItem comp in listView1.Items)

{

ws.Cells[i, j] = comp.Text.ToString();

//MessageBox.Show(comp.Text.ToString());

foreach (ListViewItem.ListViewSubItem drv in comp.SubItems)

{

ws.Cells[i, j] = drv.Text.ToString();

j++;

}

j = 1;

i++;

}

Friday, May 14, 2010

How To Call DLL Created in .Net From VBA Application

The Following steps are .....
1)First created one Class Library in .net.Writes all the function and methods which are required.

2)For Register DLL for COM INTROP we have to open Solution Explorer of Current project.

3)Select project node then select properties window.

4)Choose Configaration properties then child node with Build tab.

5)In Build tab there is check box for Register For COM Introp ,Check it.

6)Now Compile the DLL/Class Library it is register for COM Introp.

7)Now we can acess this DLL in VBA by simply add Reference of that DLL .


Hope your DLL or Class Library can build from .net to VBA................
Enjoy Code