Solved

Pls help translate to VB

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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