We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Copy data from one worksheet to another

Thread ID:

Created:

Updated:

Platform:

Replies:

93716 Mar 30,2010 04:04 PM UTC Feb 7,2013 10:37 AM UTC WinForms 8
loading
Tags: XlsIO
Srinivasa Igur
Asked On March 30, 2010 04:04 PM UTC

Hi,

I have 3 worksheets in an excel that I am creating using IWorkbook. I am in worksheet number and I need to access data from Worksheet # 3 that is already built. So I am doing this:

IWorksheet etfSheet = workbook.Worksheets[2];
IRange etfPercentRange = etfSheet.Range["A6:A3000"];

however the etfSheet is not valid. I need to access the row #6 on the Worksheet #2 in Worksheet #0. How can I do this?

Thanks.

Sathish Babu R [Syncfusion]
Replied On March 31, 2010 09:07 AM UTC

Hi Srinivasa,

Thank you for using Syncfusion Products
<<<
I have 3 worksheets in an excel that I am creating using IWorkbook. I am in worksheet number and I need to access data from Worksheet # 3 that is already built. So I am doing this:
IWorksheet etfSheet = workbook.Worksheets[2];
IRange etfPercentRange = etfSheet.Range["A6:A3000"];
>>>>
Could you please try with the below sample and let us know if this helps.

<<<<<
I need to access the row #6 on the Worksheet #2 in Worksheet #0. How can I do this?
>>>>>
we cannot access the row #6 on the Worksheet #2 in Worksheet #0, we can access only cells.

We have copied A1 Cell content of Worksheet#2 in Worksheet#0,
Code:
workbook.Worksheets[0].Range["F11"].Text = workbook.Worksheets[0].Range["Sheet3!A1"].Text;

And Other Copy Process
we have copied the row from Worksheet #2 to Worksheet #0
we copied the column from Worksheet #2 to Worksheet #1

Please try this and let us know if you have any questions.

CopySheet2Sheet2049508446.zip

Regards
Sathish Babu R

Srinivasa Igur
Replied On March 31, 2010 01:22 PM UTC

Thanks. I did something like this ...

From the scope of Worksheet("Summary")

IWorksheet etfSheet = workbook.Worksheets["ETF"];
IRange etfPercentRange = etfSheet.Range["A6:FZ6"];
IRange etfSymbol = etfSheet.Range["A2:FZ2"];

So I a m getting a range that is a row from the other workshet and I am able to access individual cells from the Range above:

etfSymbol.Cells[1].Text

I have an different issue. The individual cells are formulas and I need to get the value of the formula for some conditional processing. As an eg. based on the above:

if ( etfPercentRange.Cells[col].FormulaNumberValue > 5.0)
then copy over to the current worksheet.

However I am not able to get the value from Text, FormulaNumberValue or any other fields. Is there a way to get this?

Thanks for all the help.

Srinivasa Igur
Replied On March 31, 2010 04:08 PM UTC

I see that the FormulaNumberValue is alawys 0.0. I am not sure if this is a bug or if I am using it wrongly.

Sathish Babu R [Syncfusion]
Replied On April 1, 2010 05:56 AM UTC

Hi Srinivasa,

Thank you for using Syncfusion Products

We are afraid that we were not able to reproduce the issue on our side.

If(percentRange.Cells[col].FormulaNumberValue >= 50)

We used the FormulaNumberValue Property, it working fine (See the below sample code). We used to execute this with the Essential Studio V8.1.0.30.

CopySheet2Sheet43242984.zip

Srinivasa Igur
Replied On April 1, 2010 12:50 PM UTC

Thanks for the example. The example works in my system and I found the issue on my side.

The formula cell that I am loking at has a number format of "%#0.00", so this represnts a number such as 0.00125 as %0.125. However the FormulaNumberValue is having 0.0. How can I get to the formated value?

Thanks for the help.

Sathish Babu R [Syncfusion]
Replied On April 1, 2010 02:49 PM UTC

Hi Srinivasa,

Thank you for using Syncfusion Products,

We used to provide a Property to get the formula cell text by using DisplayText Property, Please refer to the code-snippet below.

percentRange.Cells[col].DisplayText

However, because of “%#0.00” format DisplayText returns Text(‘2.55%’) instead of Number (0.255 or 2.55) and

DisplayText returns Text (‘$1,90,000.00’) instead of Number(190000.00) for “$#,##,##0.00” format.

Sobiya Ayub
Replied On February 5, 2013 09:58 AM UTC

Hi Sathish,

I need to copy data from one sheet to another at once, m able to copy cell by cell,
is there any option to copy the complete range at once?
I want to use something like this. where last row and last column are also specified.

workbook.Worksheets[3].Range[1,1,30,50].Text = workbook.Worksheets[1].Range[1,1,30,50].Text;



Manikandan M [Syncfusion]
Replied On February 7, 2013 10:37 AM UTC

Hi Srinivasa,

 

Thanks for your patience.

 

Currently we don’t provide the support for copying the text values from complete range to another range. Whereas we have created the workaround for copying the one range values to another range and have attached the same in the below link. Please make use of this and let us know if this helps you.

 

 

Sample link: CopyDatas.zip

 

Please let us know if you need any clarifications.

 

Thanks,

Manikandan M.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;