在拆分为新工作表时保持值 [英] maintain values while splitting into new worksheet

查看:72
本文介绍了在拆分为新工作表时保持值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要使用openxml在不同的工作表中维护excel中的单元格值。



我有6列A,B,C,D,E,F其中'A'有720行,'B'被分成6行120行,'C'有120行,'D'被分为5个元素,每个元素有24行,'E'有24行,'F'有8个元素,每行有3行。



每个工作表只能有25行。所以其他行数据需要转移到下一个工作表..直到720行结束。



分割并填充工作表中的值,需要第26行作为下一个工作表中的第一行。



我试图通过使用单元格引用来实现它,但我无法实现它。我试过谷歌,我无法得到正确的解决方案。



请帮我解决。

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.

推荐答案

请阅读我对这个问题的评论。



正如我所提到的,你需要遍历范围内的单元格集合(在你的例子中: A1:A720 )。



请按照以下链接:

如何:解析和阅读大型电子表格文档(Open XML SDK) [ ^ ]

如何:检索电子表格文档中的单元格值(Open XML SDK) [ ^ ]

如何:检索一个列表电子表格文档中的ksheets(Open XML SDK) [ ^ ]



步骤:

1)声明变量: CurrentRow DestinationRow 存储全局处理行数,当前复制的行和目标行

2)而 CurrentRow< rows.count>< /rows.count> 在有效范围内转到第3步

3)执行:

a)将范围复制到另一张表格

b)增加 DestinationRow + = 1 直到 DestinationRow< 26

4)如果DestinationRow = 25

a)更改目标表(如有必要,创建新表),

b)重置 DestinationRow = 1;

5)循环(转到2)
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)


这篇关于在拆分为新工作表时保持值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆