本文介绍了在c#中拆分行和列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,我有一些行和列的数据如下:

Dear Sir i have some data with rows and column as folows:

manas   20 10 30 80 40 50 60 70
mani    11 12 13 14 15 16 17 18
mami    21 22 23 24 25 26 27 28
raju    22 33 44 55 66 77 88 89
sajit   42 15 45 11 22 10 20 25



i希望分割数据,比如

它会先读取 3行和4列。


i want to split the data like
it will read first 3 rows and 4 columns.like

manas   20 10 30 
mani    11 12 13 
mami    21 22 23 





then



then

raju    22 33 44 
sajit   42 15 45 



then


then

80 40 50 60
14 15 16 17
24 25 26 27



then


then

55 66 77 88
11 22 10 20





代码:



code:

for (int i = 0; i < lstRows.Count; i++)

       {

           int counter = 1;

           for (int j = NoOffixedcolumn; j < lstColumns.Count; j++) //Check with no of columns

           {

               lines += lstRows[i].ChildNodes[j].InnerText + " "; //lstColumns[j].InnerText.ToString();

               if (counter % NoOfColumn == 0)//When it is equla with your no of columns upto last stage

               {

                   Response.Write(lines + "<br/>");
                   lines = fixColumns + " ";
               }
               if (j == lstColumns.Count - 1 && counter % NoOfColumn != 0) //Check at last column
               {
                   Response.Write(lines + "<br/>");
               }
               counter += 1;
           }
       }

推荐答案

Index[0] >= print row[0]col[0] to row[2]col[3]
Index[1] >= print row[3]col[0] to row[4]col[3]

Index[2] >= print row[0]col[4] to row[2]col[8]
Index[3] >= print row[3]col[4] to row[4]col[8]



并进行迭代在索引上。希望这可以解决您的问题


and do an iteration on the index. Hopefully this should sort your problem


这篇关于在c#中拆分行和列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 13:40