国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

csharp: Aspose.Words create table

2019-11-17 02:45:15
字體:
供稿:網(wǎng)友

csharp: aspose.Words create table

 /// <summary>        /// 20141118        /// Geovin Du        /// Aspose.Words創(chuàng)建表        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        PRotected void Page_Load(object sender, EventArgs e)        {            try            {                //實(shí)例化一個(gè)新的Word Document                //也可以在Aspose.Words.Document doc = newAspose.Words.Document(path)中加path參數(shù),                //此path指向你設(shè)計(jì)好的Word模板路徑                Aspose.Words.Document doc = new Aspose.Words.Document();                DocumentBuilder builder = new DocumentBuilder(doc);                //設(shè)置單元格內(nèi)容對(duì)齊方式                builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;                //清除設(shè)置                builder.PageSetup.ClearFormatting();                DataTable tbl = new DataTable();// m_db.GetDataTable(sql, m_cn);                tbl.Columns.Add("XZ", typeof(int));                tbl.Columns.Add("ZPPATH", typeof(string));                tbl.Columns.Add("XM", typeof(string));                tbl.Columns.Add("SZDW", typeof(string));                tbl.Columns.Add("DWDH", typeof(string));                tbl.Columns.Add("SJHM", typeof(string));                tbl.Columns.Add("DWYB", typeof(string));                tbl.Columns.Add("DZYJ", typeof(string));                tbl.Rows.Add(1, "", "geovindu", "締友計(jì)算機(jī)信息技術(shù)有限公司;軟件工程師", "82397501", "13824350518", "518003", "463588883@QQ.com");                tbl.Rows.Add(2, "", "涂年生","締創(chuàng)智能工程技術(shù)有限公司;網(wǎng)絡(luò)工程師", "82397502", "13824350518", "518003", "geovindu@qq.com");                tbl.Rows.Add(3, "", "涂聚文", "締建智能建筑工程有限公司;UI設(shè)計(jì)師", "82397503", "13824350518", "518003", "463588883@qq.com");                List<string> list = new List<string>();                if (tbl != null && tbl.Rows.Count > 0)                {                    //加載小組                    for (int i = 0; i < tbl.Rows.Count; i++)                    {                        if (!list.Contains(tbl.Rows[i]["XZ"].ToString()))                        {                            list.Add(tbl.Rows[i]["XZ"].ToString());                        }                    }                    double imgcellwidth = 85;                    double imgcellheight = 120;                    double cellwidth = 165;                    double cellheight = 18.5;                    //匹配小組中的學(xué)員                    builder.StartTable();//開始畫Table                                 builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; // RowAlignment.Center;                                     string xz = string.Empty;                    int count = 0;                    int rowcount = 0;                    for (int n = 0; n < list.Count; n++)                    {                        xz = list[n];                        builder.RowFormat.Height = 20;                        //插入Table單元格                        builder.InsertCell();                        //Table單元格邊框線樣式                        builder.CellFormat.Borders.LineStyle = LineStyle.Single;                        //Table此單元格寬度                        builder.CellFormat.Width = 500;                        //此單元格中內(nèi)容垂直對(duì)齊方式                        builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;                        builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.None;                        builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;                        //字體大小                        builder.Font.Size = 11;                        //是否加粗                        builder.Bold = true;                        //向此單元格中添加內(nèi)容                        builder.Write(xz);                        //Table行結(jié)束                        builder.EndRow();                        builder.Bold = false;                        DataRow[] rows = tbl.Select("xz='" + xz + "'");                        for (int i = 0; i < rows.Length; i = i + 2)                        {                            count++;                            rowcount = (count - 1) * 6 + 1 + n;                            //第一行                            builder.InsertCell();                            builder.RowFormat.Height = imgcellheight;                            builder.CellFormat.Borders.LineStyle = LineStyle.Single;                            //合并行單元格                            builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.First;                            builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;                            builder.CellFormat.TopPadding = 2;                            builder.CellFormat.WrapText = false;                            builder.CellFormat.Width = imgcellwidth;                            if (!string.IsNullOrEmpty(rows[i]["ZPPATH"].ToString()))                            {                                //向此單元格中插入圖片                                Shape shape = new Shape(doc, ShapeType.Image);                                string url = System.Configuration.ConfigurationManager.AppSettings["UserPhotosSitePath"] + "http://" + rows[i]["ZPPATH"].ToString();                                shape.ImageData.SetImage(url);                                shape.Width = imgcellwidth - 2;                                shape.Height = imgcellheight;                                shape.HorizontalAlignment = HorizontalAlignment.Center;                                CompositeNode node = shape.ParentNode;                                //把此圖片移動(dòng)到那個(gè)單元格中                                builder.MoveToCell(0, rowcount, 0, 0);                                builder.InsertNode(shape);                            }                            builder.InsertCell();                            builder.RowFormat.Height = cellheight;                            builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;                            builder.CellFormat.Borders.LineStyle = LineStyle.Single;                            builder.CellFormat.Width = cellwidth;                            builder.Write(rows[i]["XM"].ToString()); //                            builder.InsertCell();                            builder.RowFormat.Height = imgcellheight;                            builder.CellFormat.Borders.LineStyle = LineStyle.Single;                            //合并行單元格                            builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.First;                            builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;                            builder.CellFormat.Width = imgcellwidth;                            if (rows.Length > i + 1)                            {                                if (!string.IsNullOrEmpty(rows[i + 1]["ZPPATH"].ToString()))                                {                                    Shape shape = new Shape(doc, ShapeType.Image);                                    string url = System.Configuration.ConfigurationManager.AppSettings["UserPhotosSitePath"] + "http://" + rows[i + 1]["ZPPATH"].ToString();                                    shape.ImageData.SetImage(url);                                    shape.Width = imgcellwidth - 2;                                    shape.Height = imgcellheight;                                    shape.HorizontalAlignment = HorizontalAlignment.Center;                                    CompositeNode node = shape.ParentNode;                                    builder.MoveToCell(0, rowcount, 2, 0);                                    builder.InsertNode(shape);                                }                            }                            builder.InsertCell();                            builder.RowFormat.Height = cellheight;                            builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;                            builder.CellFormat.Borders.LineStyle = LineStyle.Single;                            builder.CellFormat.Width = cellwidth;                            if
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 措勤县| 福建省| 阿克苏市| 巴林左旗| 嘉禾县| 奇台县| 福建省| 湘阴县| 庆城县| 阿拉尔市| 镇康县| 中卫市| 宜兰县| 渑池县| 黄骅市| 海淀区| 石台县| 昌平区| 苍山县| 桦南县| 西和县| 五河县| 三台县| 温州市| 凭祥市| 台前县| 龙门县| 罗平县| 平果县| 孟津县| 汝南县| 天峨县| 凯里市| 九江市| 通化市| 井研县| 新疆| 昭苏县| 闽清县| 定远县| 广平县|