Solved

Pls help translate to VB

Posted on 2006-06-23
2
344 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

785 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