How to? Complex tables and graphics like excell.

BlitzMX

Member
Joined
Oct 16, 2012
Messages
12
Programming Experience
Beginner
Hello

I am looking for a way to import several excell reports to build a statistic form like the one bellow, how can i do this in Visual Basic.net 2010?
What function or component should i use to presente data the same way and more, with some colors and everything?
print.JPG
Best regards
Thank you
 
Last edited:
Hi,

You can access excel files as demonstrated in the following example:-

VB.NET:
Imports Microsoft.Office.Interop
 
Public Class Form1
 
  Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Dim xlApp As New Excel.Application
    Dim xlWorkBook As Excel.Workbook
    Dim xlWorkSheet As Excel.Worksheet
 
    xlWorkBook = xlApp.Workbooks.Open("d:\temp\Book1.xls")
    xlWorkSheet = xlWorkBook.Worksheets("sheet1")
    For xlRow As Integer = 1 To xlWorkSheet.UsedRange.Rows.Count
      For xlCol As Integer = 1 To xlWorkSheet.UsedRange.Columns.Count
        MsgBox(xlWorkSheet.Cells(xlRow, xlCol).value)
      Next
    Next
    xlWorkBook.Close()
    xlApp.Quit()
  End Sub
I would then suggest that the most useful control at your disposal to accommodate what you want to do is the DataGridView control.

Hope that helps to get you started.

Cheers,

Ian
 
I am getting a lot of erros, i have tryed before to import excell stuff but never managed to make it work.
Thank you

print2.JPG
 
Hi,

Apologies, my mistake, I forgot to mention you need to add a reference to Microsoft.Office.Interop.Excel. In solution explorer, select add reference, Select .NET and then find the component I mentioned.

Cheers,

Ian
 
Hi,

Apologies, my mistake, I forgot to mention you need to add a reference to Microsoft.Office.Interop.Excel. In solution explorer, select add reference, Select .NET and then find the component I mentioned.

Cheers,

Ian

I couldn´t find it in .NET so i searched the web and found this.
Add Reference, COM tab, Microsoft Excel Object Library...

And i think it works but the file is not found so ill work on that.

:D
Thank you very much.
 
Hi,

A quick tip for you. When adding a reference, the objects are never typically listed in order, click on the Component Name header and it will sort them in order for you. You should be able to find it then. By the way I use version 14.0.0.0

Cheers,

Ian
 
I think our posts overlapped. Have you picked up and tried my previous post yet?

Ian

Yes yes, it was the solution for the problem, but it was not in .NET tab, it was in COM tab under another "Office Excell something name".
Now... it appears to work but i get the namefile wrong, i checked and its correct.

What could be the problem?
 
Hi,

Sorry, I do not understand:-



Can you better explain what you mean.

Cheers,

Ian


You told me to import the Office excell reference.. I did that. (I didn´t found it in the .NET tab so i searched the web and found that ther was one in the COM tab) All errors desappeared.
Now... when i run the code i get an error for the filename but i checked and it is correct.

I am trying to open at C:\test.xls
But it says 'C:\test.xls' could not be found

View attachment 3455

Thank you
 
Not really sure here then.

Can you post the code that you have so far including your Imports statement and tell me the exact the name of the component that you eventually added in your reference.

I need to leave for a while now, but I will try and have a look again later.

Cheers,

Ian
 
Not really sure here then.

Can you post the code that you have so far including your Imports statement and tell me the exact the name of the component that you eventually added in your reference.

I need to leave for a while now, but I will try and have a look again later.

Cheers,

Ian

I imported - Microsoft Excel 12.0 Object Library - type COM.

print3.JPG

No hurries
Thank you for everything.
 
Back
Top