| | |
| | | { |
| | | table.Columns[1].Width = Width - 4; |
| | | //table.Columns[2].Width = Width * 2 + 6; |
| | | table.Columns[2].Width = Titles.Length > 3 ? Width * 5-10 : Width * 8 + 12; |
| | | table.Columns[2].Width = Titles.Length > 3 ? Width * 5 - 10 : Width * 8 + 12; |
| | | } |
| | | if (FontSize != 0) |
| | | { |
| | |
| | | return table; |
| | | } |
| | | |
| | | public void GenerateInfos(string[] bookMarks, double[] bookInfos,ref WordHelper wordHelper) |
| | | public void GenerateInfos(string[] bookMarks, double[] bookInfos, ref WordHelper wordHelper) |
| | | { |
| | | for (int i = 0; i < bookInfos.Length; i++) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | public List<Range> FindAll(Range range, string findText) |
| | | public List<Range> FindAll(Range range, string findText) |
| | | { |
| | | int start = range.Start; |
| | | int end = range.End; |
| | |
| | | return ranges; |
| | | } |
| | | |
| | | public void GenerateTables(System.Data.DataTable dt,string bookMark, ref WordHelper wordHelper) |
| | | public void GenerateTables(System.Data.DataTable dt, string bookMark, ref WordHelper wordHelper) |
| | | { |
| | | string[] Titles = new string[dt.Columns.Count]; |
| | | for (int i = 0; i < dt.Columns.Count; i++) |
| | | { |
| | | if(i==0)continue; |
| | | if (i == 0) continue; |
| | | Titles[i] = dt.Columns[i].ColumnName; |
| | | } |
| | | Table table = wordHelper.AddTableTitles(Titles, bookMark, dt.Rows.Count+1, 30, 10, |
| | | Table table = wordHelper.AddTableTitles(Titles, bookMark, dt.Rows.Count + 1, 30, 10, |
| | | ref wordHelper); |
| | | //填充非根节点 |
| | | for (int i = 0; i < dt.Rows.Count; i++) |
| | |
| | | for (int j = 0; j < dt.Columns.Count; j++) |
| | | { |
| | | //if (j >= 7) break; |
| | | if ((j == 2 || j==4) && dt.Rows[i][j].ToString()!="") //插入图片 |
| | | if ((j == 2 || j == 4) && dt.Rows[i][j].ToString() != "") //插入图片 |
| | | { |
| | | object range = table.Cell(i+2, j+1).Range; |
| | | string[] strImgs = dt.Rows[i][j].ToString().Split(new char[] {','}); |
| | | object range = table.Cell(i + 2, j + 1).Range; |
| | | string[] strImgs = dt.Rows[i][j].ToString().Split(new char[] { ',' }); |
| | | for (int m = 0; m < strImgs.Length; m++) |
| | | { |
| | | wordHelper.InsertPicture(range, System.Web.HttpContext.Current.Server.MapPath(strImgs[m]),70,50,1); |
| | | wordHelper.InsertPicture(range, System.Web.HttpContext.Current.Server.MapPath(strImgs[m]), 70, 50, 1); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wordHelper.InsertCell(table, i + 2, j+1, dt.Rows[i][j].ToString()); |
| | | wordHelper.InsertCell(table, i + 2, j + 1, dt.Rows[i][j].ToString()); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | wordDoc = wordApp.Documents.Add(ref templateName, ref missing, ref missing, ref missing); |
| | | wordDoc.SpellingChecked = false;//关闭拼写检查 |
| | | wordDoc.ShowSpellingErrors = false; |
| | | |
| | | |
| | | //wordDoc = wordApp.Documents.Open(ref templateName, ref missing, |
| | | // ref missing, ref missing, ref missing, ref missing, ref missing, |
| | | // ref missing, ref missing, ref missing, ref missing, ref missing, |
| | |
| | | wordDoc.Application.ActiveDocument.InlineShapes[1].Height = hight; //设置图片高度 |
| | | } |
| | | |
| | | public void InsertPicture(object range, string picturePath, float width, float hight,int no) |
| | | public void InsertPicture(object range, string picturePath, float width, float hight, int no) |
| | | { |
| | | object linkToFile = false; //图片是否为外部链接 |
| | | object saveWithDocument = true; //图片是否随文档一起保存 |