Home > Net >  NPOI export word how to make the first line of cell also merge
NPOI export word how to make the first line of cell also merge

Time:09-26




 XWPFTableRow MyRow=table. GetRow (0);//get the first line 

XWPFTableCell cell=MyRow. GetCell (0);//get a cell, create cell creates a CT_P

CT_Tc CTTC=cell. GetCTTc ();
CT_TcPr ctPr=CTTC. AddNewTcPr ();
CT_Row m_NewRow=new CT_Row ();
MyRow=new XWPFTableRow (m_NewRow, table);
Table. AddRow (MyRow);//must be!!!!!!
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
CTTC=cell. GetCTTc ();
CtPr=CTTC. AddNewTcPr ();
CtPr. AddNewVMerge (). Val=ST_Merge. Restart.//merge
CtPr. AddNewVAlign (). Val=ST_VerticalJc. Center;//vertical
Table. RemoveRow (0);

M_NewRow=new CT_Row ();
MyRow=new XWPFTableRow (m_NewRow, table);
Table. AddRow (MyRow);
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
CTTC=cell. GetCTTc ();
CtPr=CTTC. AddNewTcPr ();
CtPr. AddNewVMerge (). Val=ST_Merge. @ the continue;//merge

M_NewRow=new CT_Row ();
MyRow=new XWPFTableRow (m_NewRow, table);
Table. AddRow (MyRow);
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
Cell=MyRow. CreateCell ();
CTTC=cell. GetCTTc ();
CtPr=CTTC. AddNewTcPr ();
CtPr. AddNewVMerge (). Val=ST_Merge. @ the continue;//merge rows

CodePudding user response:

With EXCEL template fill you hard-coded workload is too heavy, and the meaning is not big,
Suggestion first reading EXCEL, variables are read out and replaced to save,
EXCEL templates can be combined by the customers themselves, to increase the information such as title,
We need to do is to define a variable, such as single head double table field $$beginning, repeat single begins with $,

CodePudding user response:

Hello, NPOI export word make the first line of cell merge how??
  •  Tags:  
  • C#
  • Related