本帖最后由 KingMan 于 2017-6-20 19:09 编辑
如何获取从左到右获取表格的顺序,注意,表格中可能出现嵌套的情况。
我进行过多次试验,当期版本中有几个问题,在Doc设计好的格式,复制黏贴到TXControl中,拆分的单元格可能会被拆分啦新表。
在尝试的过程中,本来想通过单元格的Start,Postion 等信息来 将单元格排序,但是发现Position 可能会相同。单元格的Start和单元格从左到右排序不一致。
如下面的相关信息:
Row = 1,Column = 1,Length = 5,Text = 2010年, Start = 2, Position = 5
Row = 1,Column = 3,Length = 2,Text = 意识, Start = 8, Position = 1134
Row = 1,Column = 4,Length = 2,Text = 体温, Start = 11, Position = 1658
Row = 1,Column = 5,Length = 2,Text = 脉搏, Start = 14, Position = 2221
Row = 1,Column = 6,Length = 2,Text = 呼吸, Start = 17, Position = 2835
Row = 1,Column = 7,Length = 2,Text = 血压, Start = 20, Position = 3402
Row = 1,Column = 8,Length = 5,Text = 血氧饱和度, Start = 23, Position = 3686
Row = 1,Column = 9,Length = 2,Text = 吸氧, Start = 29, Position = 4678
Row = 1,Column = 10,Length = 2,Text = 入量, Start = 32, Position = 5245
Row = 1,Column = 11,Length = 2,Text = 出量, Start = 35, Position = 6663
Row = 1,Column = 14,Length = 4,Text = 皮肤情况, Start = 38, Position = 8080
Row = 1,Column = 15,Length = 4,Text = 管路护理, Start = 43, Position = 8647
Row = 1,Column = 16,Length = 2,Text = 其1, Start = 48, Position = 9214
Row = 1,Column = 17,Length = 2,Text = 其2, Start = 51, Position = 9639
Row = 1,Column = 18,Length = 3,Text = 其3, Start = 54, Position = 10065
Row = 1,Column = 19,Length = 8,Text = 病情观察及措施, Start = 58, Position = 10632
Row = 1,Column = 20,Length = 5,Text = 护士签名, Start = 67, Position = 12474
Row = 2,Column = 1,Length = 3,Text = 日/月, Start = 73, Position = 5
Row = 2,Column = 2,Length = 2,Text = 时间, Start = 77, Position = 614
Row = 2,Column = 10,Length = 2,Text = 名称, Start = 80, Position = 5245
Row = 2,Column = 11,Length = 1,Text = 量, Start = 83, Position = 5954
Row = 2,Column = 12,Length = 2,Text = 名称, Start = 85, Position = 6663
Row = 2,Column = 13,Length = 1,Text = 量, Start = 88, Position = 7230
程序代码片段:
Table pTable = textControl1.Tables.GetItem();
if (pTable == null)
return;
Table pOuterMostTable = pTable.OuterMostTable;
if (pOuterMostTable == null)
pOuterMostTable = pTable;
String sX = "";
foreach (TableCell pNext in pOuterMostTable.Cells)
{
if (pNext.Length == -1)
continue;
sX += String.Format("Row = {0},Column = {1},Length = {2},Text = {3}, Start = {4}, Position = {5}\n",
pNext.Row, pNext.Column, pNext.Length, pNext.Text, pNext.Start, pNext.Position);
}
sX += "\n";
foreach (Table pNextTable in pOuterMostTable.NestedTables)
{
foreach (TableCell pNext in pNextTable.Cells)
{
if (pNext.Length == -1)
continue;
sX += String.Format("Row = {0},Column = {1},Length = {2},Text = {3}, Start = {4}, Position = {5}\n",
pNext.Row, pNext.Column, pNext.Length, pNext.Text, pNext.Start, pNext.Position);
}
}
尝试啦多次,拿这个控件没有办法啦,有没有什么办法可以知道从左到右单元格排序,如果能,给下Demo,如果不行,能不能联系下厂商那边有没有处理方法。
特别是下面这个表格,处理起来调试的结果完全和预期不一致。
|
|