Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need have a maintain the cell values in an excel in different worksheets using openxml.

I have 6 columns A,B,C,D,E,F where 'A' has 720 rows, 'B' is splitted in to 6 elements with 120 rows, 'C' with 120 rows, 'D' is splitted in to 5 elements each with 24 rows , 'E' with 24 rows and 'F' with 8 elements with 3 rows each.

Each worksheet can have only 25 rows. so other rows data needed to be shifted to next worksheet.. like wise till end of 720 rows.

after splitting and populating the values from in worksheet, 26th row needed to be as 1st row in next worksheet.

This I have tried to do it by using cell reference but I couldn't achieve it. I have tried in google, I couldn't get the correct solution.

Please help me getting a solution.
Posted
Comments
Maciej Los 8-Jul-13 10:05am    
What have you done till now?
Where are you stuck?
All you need to do is to loop through the collection of cells...

1 solution

Please, read my comment to the question.

As i mentioned, you need to loop through the collection of cells in range (in your example: A1:A720).

Please, follow below links:
How to: Parse and read a large spreadsheet document (Open XML SDK)[^]
How to: Retrieve the values of cells in a spreadsheet document (Open XML SDK)[^]
How to: Retrieve a list of the worksheets in a spreadsheet document (Open XML SDK)[^]

Steps to do:
1) declare variables: CurrentRow and DestinationRow to store the global number of processing row, currently copied row and destination row
2) while CurrentRow<rows.count></rows.count> in active range go to step 3
3) do:
a) copy range to another sheet
b) increase DestinationRow+=1 until DestinationRow<26
4) if DestinationRow=25
a) change the destination sheet (if necessary, create new one),
b) reset DestinationRow=1;
5) loop (go to 2)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900