@ -1539,9 +1539,19 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
{
//添加表格指定表格的行数和列数(2行,5列)
Table table = section . AddTable ( true ) ;
table . ResetCells ( D2date . Split ( ',' ) . Count ( ) + 1 , TableNums ) ;
//把第一列从第一行到所有项目的所有列全部合并
//在此次判断是否是最后一个表格,如果是根据实际剩余得元素个数生成列
if ( num = = 1 )
{
int TableNumsS = TableNums - ( TableNum - D3date . Split ( ',' ) . Count ( ) ) ;
table . ResetCells ( D2date . Split ( ',' ) . Count ( ) + 1 , TableNumsS ) ;
}
else
{
table . ResetCells ( D2date . Split ( ',' ) . Count ( ) + 1 , TableNums ) ;
}
//把第一列从第一行到所有项目的所有列全部合并
//如果需要合并行使用下面的例子(把第一行的第一列到第三列合并)
//table.ApplyHorizontalMerge(0, 0, 2);
int D2Num = D2date . Split ( ',' ) . Count ( ) ;
@ -1939,7 +1949,7 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
D1dateNum = 1 ;
}
int rows = 0 ;
int d2 ss = 0 ;
int d2 DATANUM = 0 ; //记录当前牌号数据条数
int tanum = 2 ; //元素从第几列开始
//把一个表格拆成所需要的多个表格
@ -1951,8 +1961,20 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
//添加表格指定表格的行数和列数(2行,5列)
Table table = section . AddTable ( true ) ;
//创建一个指定行和列得表格
table . ResetCells ( data . Rows . Count + 1 , TableNums ) ;
//在此次判断是否是最后一个表格,如果是根据实际剩余得元素个数生成列
if ( num = = 1 )
{
int TableNumsS = TableNums - ( TableNum - D3date . Split ( ',' ) . Count ( ) ) ;
table . ResetCells ( data . Rows . Count + 1 , TableNumsS ) ;
}
else
{
table . ResetCells ( data . Rows . Count + 1 , TableNums ) ;
}
////添加表格指定表格的行数和列数(2行,5列)
//Table table = section.AddTable(true);
////创建一个指定行和列得表格
//table.ResetCells(data.Rows.Count + 1, TableNums);
//循环牌号
//循环每个牌号
@ -1976,10 +1998,10 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
sqls = D1 + "='" + D1date . Split ( ',' ) [ j ] + "'" ;
}
//拿到当前牌号得数据条数
d2 ss = 0 ;
d2 ss = data . Select ( sqls ) . Count ( ) ;
d2 DATANUM = 0 ;
d2 DATANUM = data . Select ( sqls ) . Count ( ) ;
////拿到项目名称
if ( d2 ss > 0 )
if ( d2 DATANUM > 0 )
{
for ( int i = 0 ; i < data . Select ( sqls ) . Count ( ) ; i + + )
{
@ -2192,14 +2214,13 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
range . CharacterFormat . Bold = false ;
table [ row , Q ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ row , Q ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
} //循环元素值结束
row = row + 1 ;
} //循环行结束
rows = rows + d2 ss ;
rows = rows + d2 DATANUM ;
} //循环牌号结束
table . TableFormat . HorizontalAlignment = RowAlignment . Center ; //整个表格居中
@ -2243,6 +2264,7 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
}
}
# region
/// <summary>
/// 替换二维表单@BKGY质量要点
@ -2251,16 +2273,17 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
/// <param name="D1">一级表头</param>
/// <param name="D2">二级表头</param>
/// <param name="D3">三级表头</param>
/// <param name="D4">四级表头</param>
/// <param name="TextName">替换字符串</param>
/// <param name ="path"> 文件路径 </ param >
public void ZLYDFORMDoc ( DataTable data , string D1 , String D2 , String D3 , string TextName , string path )
public void ZLYDFORMDoc ( DataTable data , string D1 , string D2 , string D3 , string D4 , string TextName , string path )
{
int TableNum = 13 ; //一行显示多少个元素
int TableNums = TableNum + 2 ; //显示多少列2表示签名加一列牌号 和项目
int TableNums = TableNum + 3 ; //显示多少列2表示签名加一列牌号 、坯型 和项目
string rtf = string . Empty ;
if ( data . Rows . Count > 0 )
{
string D1date = "" , D2date = "" , D3date = "" ;
string D1date = "" , D2date = "" , D3date = "" , D4date = "" ;
///循环拿到牌号,
///循环拿到项目,
///循环拿到元素
@ -2280,27 +2303,7 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
if ( d1dd ) { D1date = D1date + data . Rows [ i ] [ D1 ] . ToString ( ) + "," ; }
}
//拿到项目名称
if ( data . Rows [ i ] [ D2 ] . ToString ( ) ! = "-1" )
{
bool d1dds = true ;
foreach ( var item in D2date . Split ( ',' ) )
{
if ( item = = data . Rows [ i ] [ D2 + "Text" ] . ToString ( ) )
{
d1dds = false ; break ;
}
}
if ( d1dds ) { D2date = D2date + data . Rows [ i ] [ D2 + "Text" ] . ToString ( ) + "," ; }
}
//if (data.Rows[i][D3].ToString() != "-1")
//{
// if (!D3date.Contains(data.Rows[i][D3].ToString()))
// {
// 拿到每一个元素是否都有值
// D3date = D3date + data.Rows[i][D3].ToString() + ",";
// }
//}
}
if ( D3 . Length > 0 )
{
@ -2338,23 +2341,15 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
}
}
if ( D 2date. Length > 0 & & D 3date. Length > 0 )
if ( D 3date. Length > 0 )
{
if ( D1date . Length > 0 )
{
D1date = D1date . Substring ( 0 , D1date . Length - 1 ) ;
}
D2date = D2date . Substring ( 0 , D2date . Length - 1 ) ;
D3date = D3date . Substring ( 0 , D3date . Length - 1 ) ;
/*在这里判断是否需要循环D2date把标准上限标准下限合并成标准, 内控上限内控下限合并成内控, 如果需要循环之后生成一个新的D2date字符串*/
//创建一个Document类实例,并添加section
//Document document = new Document();
//Section section = document.AddSection();
Document doc = new Document ( ) ;
doc . LoadFromFile ( path ) ;
@ -2384,107 +2379,228 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
{
D1dateNum = 1 ;
}
//循环每个牌号
for ( int j = 0 ; j < D1dateNum ; j + + )
int rows = 0 ;
int d2DATANUM = 0 ;
int tanum = 3 ; //元素从第几列开始
//把一个表格拆成所需要的多个表格
for ( int k = 0 ; k < num ; k + + )
{
int tanum = 2 ;
//元素从第几列开始
rows = 0 ;
int row = 0 ;
//查询当前牌号又多少行--D2date
//把一个表格拆成所需要的多个表格
for ( int k = 0 ; k < num ; k + + )
//添加表格指定表格的行数和列数(2行,5列)
Table table = section . AddTable ( true ) ;
//在此次判断是否是最后一个表格,如果是根据实际剩余得元素个数生成列
if ( num = = 1 )
{
//添加表格指定表格的行数和列数(2行,5列)
Table table = section . AddTable ( true ) ;
table . ResetCells ( D2date . Split ( ',' ) . Count ( ) + 1 , TableNums ) ;
//把第一列从第一行到所有项目的所有列全部合并
//如果需要合并行使用下面的例子(把第一行的第一列到第三列合并)
//table.ApplyHorizontalMerge(0, 0, 2);
int D2Num = D2date . Split ( ',' ) . Count ( ) ;
//string NN = "牌号";
//获取单元格(第1行第1个单元格)并添加文本内容,设置字体字号颜色等(单元格中内容及个性化设置可以根据需要来进行调整)
//Encoding NN = System.Text.Encoding.GetEncoding("GB2312");
//TextRange range = table[0, 0].AddParagraph().AppendText("牌号");
if ( ! string . IsNullOrEmpty ( D1date ) )
int TableNumsS = TableNums - ( TableNum - D3date . Split ( ',' ) . Count ( ) ) ;
table . ResetCells ( data . Rows . Count + 1 , TableNumsS ) ;
}
else
{
table . ResetCells ( data . Rows . Count + 1 , TableNums ) ;
}
////添加表格指定表格的行数和列数(2行,5列)
//Table table = section.AddTable(true);
////创建一个指定行和列得表格
//table.ResetCells(data.Rows.Count + 1, TableNums);
//bool d1dds = true;
//循环牌号
//循环每个牌号
int arrange = 0 ;
for ( int j = 0 ; j < D1dateNum ; j + + )
{
arrange = 0 ;
D2date = "" ;
D4date = "" ;
if ( j = = 0 )
{
table . ApplyVerticalMerge ( 0 , 1 , D2date . Split ( ',' ) . Count ( ) ) ;
range = table [ 0 , 0 ] . AddParagraph ( ) . AppendText ( "牌号" ) ;
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ 0 , 0 ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , 0 ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
row = 1 ;
//获取单元格(第1行第2个单元格)并添加文本
range = table [ 0 , 1 ] . AddParagraph ( ) . AppendText ( "元素" ) ;
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ 0 , 1 ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , 1 ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
else
{
tanum = 1 ;
//获取单元格(第1行第2个单元格)并添加文本
range = table [ 0 , 0 ] . AddParagraph ( ) . AppendText ( "元素" ) ;
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ 0 , 0 ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , 0 ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
row = rows + 1 ;
}
string sqls = String . Empty ;
if ( ! string . IsNullOrEmpty ( D1date ) & & D1date . Split ( ',' ) . Count ( ) > 1 )
{
sqls = D1 + "='" + D1date . Split ( ',' ) [ j ] + "'" ;
}
if ( data . Select ( sqls ) . Count ( ) > 0 )
{
bool d1dds = true ;
//拿到当前牌号下的所有数据然后循环
for ( int ii = 0 ; ii < data . Select ( sqls ) . Count ( ) ; ii + + )
{
///循环拿到当前牌号的每一条数据的坯型
string NameD4 = data . Select ( sqls ) [ ii ] [ D4 ] . ToString ( ) ;
///循环坯型判定当前坯型如果不在数组中就追加到数组中
foreach ( var item in D4date . Split ( ',' ) )
{
d1dds = true ;
if ( item = = NameD4 )
{
d1dds = false ; break ;
}
}
if ( d1dds ) { D4date = D4date + NameD4 + "," ; }
///此处拿到有多少项目
string NameD2 = data . Select ( sqls ) [ ii ] [ D2 + "Text" ] . ToString ( ) ;
foreach ( var item in D2date . Split ( ',' ) )
{
d1dds = true ;
if ( item = = NameD2 )
{
d1dds = false ; break ;
}
}
if ( d1dds ) { D2date = D2date + NameD2 + "," ; }
int D3Num = 0 ;
//此处循环元素
for ( int Q = tanum ; Q < TableNums ; Q + + )
}
}
//拿到当前牌号得数据条数
d2DATANUM = 0 ;
d2DATANUM = data . Select ( sqls ) . Count ( ) ;
//////拿到项目名称
//if (d2ss > 0)
//{
// for (int i = 0; i < data.Select(sqls).Count(); i++)
// {
// d1dds = true;
// foreach (var item in D2date.Split(','))
// {
// if (item == data.Select(sqls)[i][D2 + "Text"].ToString())
// {
// d1dds = false; break;
// }
// }
// if (d1dds) { D2date = D2date + data.Select(sqls)[i][D2 + "Text"].ToString() + ","; }
// }
//}
if ( D2date . Length > 0 )
{
D3Num = k * TableNum + Q - tanum ;
//判断是否是最后一个表,如果是最后一个表只需要加载剩余的元素数据,其余的表格全部为"";
if ( k = = num - 1 )
D2date = D2date . Substring ( 0 , D2date . Length - 1 ) ;
}
if ( D4date . Length > 0 )
{
D4date = D4date . Substring ( 0 , D4date . Length - 1 ) ;
}
int D2Num = D2date . Split ( ',' ) . Count ( ) ;
int D4Num = D4date . Split ( ',' ) . Count ( ) ;
if ( j = = 0 )
{
arrange = 0 ;
if ( ! string . IsNullOrEmpty ( D1date ) )
{
//用当前第几个表格乘与每个表格的元素个数加上当前循环的元素个数判断是否超过总元素个数如果超过给表格空如果没有超过则给对应的数据值
if ( k * TableNum + Q - tanum < D3date . Split ( ',' ) . Count ( ) )
//table.ApplyVerticalMerge(0, 1, D2date.Split(',').Count());
range = table [ 0 , arrange ] . AddParagraph ( ) . AppendText ( "牌号" ) ;
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ 0 , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
if ( D4Num > 0 )
{
string MM = D3date . Split ( ',' ) [ D3Num ] ;
//获取单元格(第1行第Q个单元格)并添加文本
range = table [ 0 , Q ] . AddParagraph ( ) . AppendText ( MM ) ; //D3date.Split(',')[D3Num]
range . CharacterFormat . FontName = "Times New Roman" ;
range . CharacterFormat . FontSize = 10 ;
arrange = arrange + 1 ;
//获取单元格(第1行第 2 个单元格)并添加文本
range = table [ 0 , arrange] . AddParagraph ( ) . AppendText ( "坯型" ) ;
range . CharacterFormat . FontName = " 宋体 ";
range . CharacterFormat . FontSize = 1 2 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ 0 , Q ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , Q ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
table [ 0 , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
//else
//{
// //获取单元格(第1行第Q个单元格)并添加文本
// range = table[0, Q].AddParagraph().AppendText("");
// range.CharacterFormat.FontName = "Arial";
// range.CharacterFormat.FontSize = 12;
// range.CharacterFormat.TextColor = Color.Brown;
// range.CharacterFormat.Bold = true;
//}
arrange = arrange + 1 ;
//获取单元格(第1行第2个单元格)并添加文本
range = table [ 0 , arrange ] . AddParagraph ( ) . AppendText ( "元素" ) ;
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ 0 , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
else
{
string MM = D3date . Split ( ',' ) [ D3Num ] ;
//获取单元格(第1行第Q个单元格)并添加文本
range = table [ 0 , Q ] . AddParagraph ( ) . AppendText ( MM ) ; //D3date.Split(',')[D3Num]
range . CharacterFormat . FontName = "Times New Roman" ;
range . CharacterFormat . FontSize = 10 ;
tanum = 2 ;
if ( D4Num > 0 )
{
arrange = arrange + 1 ;
tanum = 3 ;
//获取单元格(第1行第2个单元格)并添加文本
range = table [ 0 , arrange ] . AddParagraph ( ) . AppendText ( "锭坯型" ) ;
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ 0 , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
//获取单元格(第1行第2个单元格)并添加文本
range = table [ 0 , arrange ] . AddParagraph ( ) . AppendText ( "元素" ) ;
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ 0 , Q ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , Q ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
table [ 0 , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
} //循环表头结束
int D3Num = 0 ;
//此处循环元素
for ( int Q = tanum ; Q < TableNums ; Q + + )
{
D3Num = k * TableNum + Q - tanum ;
//判断是否是最后一个表,如果是最后一个表只需要加载剩余的元素数据,其余的表格全部为"";
if ( k = = num - 1 )
{
//用当前第几个表格乘与每个表格的元素个数加上当前循环的元素个数判断是否超过总元素个数如果超过给表格空如果没有超过则给对应的数据值
if ( k * TableNum + Q - tanum < D3date . Split ( ',' ) . Count ( ) )
{
string MM = D3date . Split ( ',' ) [ D3Num ] ;
//获取单元格(第1行第Q个单元格)并添加文本
range = table [ 0 , Q ] . AddParagraph ( ) . AppendText ( MM ) ; //D3date.Split(',')[D3Num]
range . CharacterFormat . FontName = "Times New Roman" ;
range . CharacterFormat . FontSize = 10 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ 0 , Q ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , Q ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
}
else
{
string MM = D3date . Split ( ',' ) [ D3Num ] ;
//获取单元格(第1行第Q个单元格)并添加文本
range = table [ 0 , Q ] . AddParagraph ( ) . AppendText ( MM ) ; //D3date.Split(',')[D3Num]
range . CharacterFormat . FontName = "Times New Roman" ;
range . CharacterFormat . FontSize = 10 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ 0 , Q ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ 0 , Q ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
} //循环表头结束
arrange = 0 ;
}
int numD4 = 0 ;
int ford4 = 0 ;
int d4datanum = 0 ; //记录循环到第几个锭坯型
//这里循环行
for ( int W = 0 ; W < D2Num ; W + + )
{
@ -2493,38 +2609,150 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
//因为牌号单元格合并了所以这里判断只有第一次循环的时候给牌号赋值
if ( W = = 0 )
{
d4datanum = 1 ;
//获取合并的牌号行数
int merge = D2date . Split ( ',' ) . Count ( ) ;
if ( row > 1 )
{
merge = row - 1 + merge ;
}
table . ApplyVerticalMerge ( arrange , row , merge ) ;
//获取单元格(第W+1行第1个单元格)并添加文本
range = table [ W + 1 , 0 ] . AddParagraph ( ) . AppendText ( D1date . Split ( ',' ) [ j ] ) ; //D1date.Split(',')[j]
range = table [ row, arrange ] . AddParagraph ( ) . AppendText ( D1date . Split ( ',' ) [ j ] ) ; //D1date.Split(',')[j]
range . CharacterFormat . FontName = "Times New Roman" ;
range . CharacterFormat . FontSize = 9 ;
table [ W + 1 , 0 ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ W + 1 , 0 ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
table [ row , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ row , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
if ( D4Num > 0 )
{
arrange = arrange + 1 ;
if ( W = = 0 )
{
//range.CharacterFormat.TextColor = Color.Black;
//range.CharacterFormat.Bold = false;
string D4SS = D4date . Split ( ',' ) [ ford4 ] ;
//拿到当前牌号有多少条数据然后合并行
//通过牌号和坯型去查数据条数
string d4sssql = sqls + " and " + D4 + "='" + D4SS + "'" ;
//data.Select(d4sssql).Count();
numD4 = numD4 + data . Select ( d4sssql ) . Count ( ) ;
//合并单元格
table . ApplyVerticalMerge ( arrange , row , data . Select ( d4sssql ) . Count ( ) - 1 + row ) ;
range = table [ row , arrange ] . AddParagraph ( ) . AppendText ( D4SS ) ; //D2date.Split(',')[W]
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ row , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ row , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
ford4 = ford4 + 1 ;
}
else if ( W = = numD4 )
{
string D4SS = D4date . Split ( ',' ) [ ford4 ] ;
//拿到当前牌号有多少条数据然后合并行
//通过牌号和坯型去查数据条数
string d4sssql = sqls + " and " + D4 + "='" + D4SS + "'" ;
//data.Select(d4sssql).Count();
numD4 = numD4 + data . Select ( d4sssql ) . Count ( ) ;
//合并单元格
table . ApplyVerticalMerge ( arrange , row , data . Select ( d4sssql ) . Count ( ) - 1 + row ) ;
range = table [ row , arrange ] . AddParagraph ( ) . AppendText ( D4SS ) ; //D2date.Split(',')[W]
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ row , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ row , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
ford4 = ford4 + 1 ;
}
}
//}
if ( W = = 0 )
{
arrange = arrange + 1 ;
}
string D2SS = D2date . Split ( ',' ) [ W ] ;
//获取单元格(第W+1行第2个单元格)并添加文本
range = table [ row , arrange ] . AddParagraph ( ) . AppendText ( D2SS ) ; //D2date.Split(',')[W]
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ row , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ row , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
//row = row + 1;
}
else
{
///判断坯型是否为空如果不为空则合并当前坯型的行然后第一次的时候输入
if ( D4Num > 0 )
{
//arrange = arrange + 1;
if ( W = = 0 )
{
arrange = arrange - 1 ;
string D4SS = D4date . Split ( ',' ) [ ford4 ] ;
//拿到当前牌号有多少条数据然后合并行
//通过牌号和坯型去查数据条数
string d4sssql = sqls + " and " + D4 + "='" + D4SS + "'" ;
//data.Select(d4sssql).Count();
numD4 = numD4 + data . Select ( d4sssql ) . Count ( ) ;
//合并单元格
table . ApplyVerticalMerge ( arrange , row , data . Select ( d4sssql ) . Count ( ) - 1 + row ) ;
range = table [ row , arrange ] . AddParagraph ( ) . AppendText ( D4SS ) ; //D2date.Split(',')[W]
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ row , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ row , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
ford4 = ford4 + 1 ;
arrange = arrange + 1 ;
}
else if ( W = = numD4 )
{
arrange = arrange - 1 ;
string D4SS = D4date . Split ( ',' ) [ ford4 ] ;
//拿到当前牌号有多少条数据然后合并行
//通过牌号和坯型去查数据条数
string d4sssql = sqls + " and " + D4 + "='" + D4SS + "'" ;
//data.Select(d4sssql).Count();
numD4 = numD4 + data . Select ( d4sssql ) . Count ( ) ;
//合并单元格
table . ApplyVerticalMerge ( arrange , row , data . Select ( d4sssql ) . Count ( ) - 1 + row ) ;
range = table [ row , arrange ] . AddParagraph ( ) . AppendText ( D4SS ) ; //D2date.Split(',')[W]
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ row , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ row , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
ford4 = ford4 + 1 ;
arrange = arrange + 1 ;
string D2SS = D2date . Split ( ',' ) [ W ] ;
//获取单元格(第W+1行第2个单元格)并添加文本
range = table [ W + 1 , 1 ] . AddParagraph ( ) . AppendText ( D2SS ) ; //D2date.Split(',')[W]
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ W + 1 , 1 ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ W + 1 , 1 ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
else
{
string D2SS = D2date . Split ( ',' ) [ W ] ;
//获取单元格(第W+1行第2个单元格)并添加文本
range = table [ W + 1 , 0 ] . AddParagraph ( ) . AppendText ( D2SS ) ; //D2date.Split(',')[W]
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ W + 1 , 0 ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ W + 1 , 0 ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
}
if ( W = = 0 )
{
arrange = arrange + 1 ;
}
string D2SS = D2date . Split ( ',' ) [ W ] ;
//获取单元格(第W+1行第2个单元格)并添加文本
range = table [ row , arrange ] . AddParagraph ( ) . AppendText ( D2SS ) ; //D2date.Split(',')[W]
range . CharacterFormat . FontName = "宋体" ;
range . CharacterFormat . FontSize = 12 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ row , arrange ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ row , arrange ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
//row = row + 1;
}
}
int d3Knum = 0 ;
//此处循环元素
@ -2558,14 +2786,14 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
// ds = "W";
//}
//获取单元格(第W+1行第Q个单元格)并添加文本
range = table [ W + 1 , Q ] . AddParagraph ( ) . AppendText ( ds ) ;
range = table [ row , Q ] . AddParagraph ( ) . AppendText ( ds ) ;
//此处应该是元素对应的值
range . CharacterFormat . FontName = "Times New Roman" ;
range . CharacterFormat . FontSize = 10 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ W + 1 , Q ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ W + 1 , Q ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
table [ row , Q ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ row , Q ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
}
@ -2590,28 +2818,28 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
}
# endregion
//if (string.IsNullOrEmpty(ds))
//{
// ds = "W";
//}
// D2names == D2date.Split(',')[W] , D1 == D1date.Split(',')[j]
range = table [ W + 1 , Q ] . AddParagraph ( ) . AppendText ( ds ) ; //此处获取元素得SZ
//此处应该是元素对应的值
range = table [ row , Q ] . AddParagraph ( ) . AppendText ( ds ) ; //此处获取元素得SZ
//此处应该是元素对应的值
range . CharacterFormat . FontName = "Times New Roman" ;
range . CharacterFormat . FontSize = 10 ;
range . CharacterFormat . TextColor = Color . Black ;
range . CharacterFormat . Bold = false ;
table [ W + 1 , Q ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ W + 1 , Q ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
table [ row , Q ] . Paragraphs [ 0 ] . Format . HorizontalAlignment = HorizontalAlignment . Center ;
table [ row , Q ] . CellFormat . VerticalAlignment = VerticalAlignment . Middle ;
}
} //循环元素值结束
row = row + 1 ;
} //循环行结束
table . TableFormat . HorizontalAlignment = RowAlignment . Center ; //整个表格居中
//移除段落,插入表格
body . ChildObjects . Insert ( index + k , table ) ;
} //循环拆分表格结束
}
rows = rows + d2DATANUM ;
} //循环牌号结束
table . TableFormat . HorizontalAlignment = RowAlignment . Center ; //整个表格居中
//移除段落,插入表格
body . ChildObjects . Insert ( index + k , table ) ;
} //循环拆分表格结束
//保存文档
doc . SaveToFile ( path , FileFormat . Doc ) ;
BP . DA . Log . DebugWriteError ( "开始去除新3D文档水印。" ) ;
@ -2643,44 +2871,11 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
BP . DA . Log . DebugWriteError ( ex . Message ) ;
}
//docs.Paragraphs.Application;
//保存文档
//string path = "C:\\Users\\lenovo\\Desktop\\Table2.rtf";
//document.SaveToFile(path, FileFormat.Rtf);
//StreamReader read = new StreamReader(path, System.Text.Encoding.ASCII); // 文件流.
//rtf = read.ReadToEnd(); //读取完毕。
//read.Close(); // 关闭。
//int numssss = rtf.IndexOf("Evaluation ");
//string rtf1 = rtf.Substring(0, numssss);
//string rtf2 = rtf.Substring(numssss + 69, rtf.Length - numssss - 69);
//rtf = rtf1 + rtf2;
//byte[] inputBytes = Encoding.ASCII.GetBytes(rtf); //System.Convert.FromBase64String(rtf);
//FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
//fs.Write(inputBytes, 0, inputBytes.Length);
//fs.Close();
////Document replaceDocument = new Document("C:\\Users\\lenovo\\Desktop\\Table1.rtf");
//Document documents = new Document("C:\\Users\\lenovo\\Desktop\\管材类质量要点模板02.rtf");
////加载用于替换文本的文档
////使用该文档替换模板中的指定文本
//documents.Replace("<BP.3D.Frm_GCLZLYDHXCFB>", document, false, true);
//Section sectionS = documents.Sections[0];
//Table table1 = sectionS.Tables[1] as Table;
//table1.TableFormat.Borders.Horizontal.BorderType = Spire.Doc.Documents.BorderStyle.Dot;
//table1.TableFormat.Borders.Horizontal.LineWidth = 2.0f;
//table1.TableFormat.Borders.Horizontal.Color = Color.Black;
//保存文档
//documents.SaveToFile("C:\\Users\\lenovo\\Desktop\\Table3.rtf", FileFormat.Rtf);
//rtf = Cache.GetBillStr("Table2.rtf", false).Substring(0);
//System.Diagnostics.Process.Start("Table2.rtf");
}
}
}
# endregion
/// <summary>
/// 单据生成
@ -3102,9 +3297,9 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
//str = str.Replace("<BP.3D." + dtlEnName + ">", rtfFor3D);
}
}
else if ( str . IndexOf ( "BP. ZLYD 2D") ! = - 1 )
else if ( str . IndexOf ( "BP. B 2D") ! = - 1 )
{
if ( str . IndexOf ( "BP. ZLYD 2D." + dtlEnName + ">" ) ! = - 1 )
if ( str . IndexOf ( "BP. B 2D." + dtlEnName + ">" ) ! = - 1 )
{
GEEntity mainEn = null ;
MapDtl mdtl = new MapDtl ( dtlEnName ) ;
@ -3121,13 +3316,13 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
d1 = item . Key ;
}
else if ( i = = 1 )
{
d4 = item . Key ;
}
else if ( i = = 2 )
{
d2 = item . Key ;
}
//else if (i == 2)
//{
// d4 = item.Key;
//}
else
{
bool d1dd = true ;
@ -3732,9 +3927,9 @@ trgaph108\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\br
{
FORMDocs ( dt3D , d1 , d2 , d3 , dtlEnName3D , this . TempFilePath ) ;
}
else if ( str . IndexOf ( "BP. ZLYD 2D") ! = - 1 )
else if ( str . IndexOf ( "BP. B 2D") ! = - 1 )
{
ZLYDFORMDoc ( dt3D , d1 , d2 , d3 , dtlEnName3D , this . TempFilePath ) ;
ZLYDFORMDoc ( dt3D , d1 , d2 , d3 , d4 , dtlEnName3D , this . TempFilePath ) ;
}
}
catch ( Exception ex )