Solved

Pls help translate to VB

Posted on 2006-06-23
2
351 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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 …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

622 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