Solved

Pls help translate to VB

Posted on 2006-06-23
2
340 Views
Last Modified: 2008-02-01
I can't seem to get these two functions into VB

private void button1_Click(object sender, System.EventArgs e)
{
// clear this book
this.c1XLBook1.Clear();

// copy range from other books
CopyRange(@"c:\temp\book1.xls", 0, 0, 66, 10, 0);
CopyRange(@"c:\temp\book2.xls", 0, 0, 66, 10, 66);
CopyRange(@"c:\temp\book3.xls", 0, 0, 66, 10, 66+66);

// save and show the result
string fileName = @"C:\temp\test.xls";
c1XLBook1.Save(fileName);
System.Diagnostics.Process.Start(fileName);
}

private void CopyRange(string fileName, int r1, int c1, int r2, int c2,
int targetRow)
{
// get source sheet
C1XLBook book = new C1XLBook();
book.Load(fileName);
XLSheet src = book.Sheets[0];

// get destination sheet
XLSheet dst = this.c1XLBook1.Sheets[0];

// copy the values
for (int r = r1; r <= r2; r++)
{
for (int c = c1; c <= c2; c++)
{
dst[targetRow + r - r1, c].Value = src[r, c].Value;
}
}
}
0
Comment
Question by:RonaldZaal
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 16970576
Try...

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    ' clear this book
    Me.c1XLBook1.Clear()

    ' copy range from other books
    CopyRange("c:\temp\book1.xls", 0, 0, 66, 10, 0)
    CopyRange("c:\temp\book2.xls", 0, 0, 66, 10, 66)
    CopyRange("c:\temp\book3.xls", 0, 0, 66, 10, 66 + 66)

    ' save and show the result
    Dim fileName As String = "C:\temp\test.xls"
    c1XLBook1.Save(fileName)
    System.Diagnostics.Process.Start(fileName)
End Sub

Private Sub CopyRange(ByVal fileName As String, ByVal r1 As Integer, ByVal c1 As Integer, ByVal r2 As Integer, ByVal c2 As Integer, ByVal targetRow As Integer)
    ' get source sheet
    Dim book As New C1XLBook()
    book.Load(fileName)
    Dim src As XLSheet = book.Sheets(0)

    ' get destination sheet
    Dim dst As XLSheet = Me.c1XLBook1.Sheets(0)

    ' copy the values
    For r As Integer = r1 To r2
        For c As Integer = c1 to c2
            dst(targetRow + r - r1, c).Value = src(r, c).Value
        Next c
    Next r
End Sub
0
 
LVL 5

Author Comment

by:RonaldZaal
ID: 16983688
Many thanks for helping me out here.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
System32Int Error 8 56
Visual Studio editor? 1 38
Close word object 13 38
How to use odbc in vb to connect to ms sql 14 38
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now