免费爱碰视频在线观看,九九精品国产屋,欧美亚洲尤物久久精品,1024在线观看视频亚洲

      Word系列之快捷快速表格插入文字圖片

      表格插入圖片文字

      本章節(jié)講述如何在表格中插入圖片和文字,

      Word中的數(shù)據(jù)只有段落和表格;word中表格表示數(shù)據(jù)

      這是單元格內(nèi)容

      代碼如下:

      private void button2_Click(object sender, EventArgs e)

      {

      string fileName = @”HelloWord.docx”;

      using (WordprocessingDocument wd = WordprocessingDocument.Create(fileName, WordprocessingDocumentType.Document))

      {

      var mainDocx = wd.AddMainDocumentPart();

      var docx = new DocumentFormat.OpenXml.Wordprocessing.Document();

      mainDocx.Document = docx;

      var body = mainDocx.Document.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Body());

      //測試寫入表格

      string[] headerArray = new string[] { “表頭1”, “表頭2”, “表頭3”, “表頭4”, “表頭5”, “表頭6”, “表頭7”, “表頭8”, “表頭9”, “表頭10” };

      List rowList = new List();

      for (int rowI = 0; rowI < 20; rowI++)

      {

      object[] t = new object[headerArray.Length];

      for (int k = 0; k < headerArray.Length; k++)

      {

      if (k < headerArray.Length – 1)

      {

      t[k] = “第” + rowI + “行第” + k + “列”;

      }

      if (k == headerArray.Length – 1)

      {

      string imgFile = “Test_1.jpg”;

      Stream stream = File.OpenRead(imgFile);

      t[k] = stream;

      }

      }

      rowList.Add(t);

      }

      #region 添加文字和圖片表格

      #region 表格

      //表格由 Table、TableRow、TableCell 三級結(jié)構(gòu)構(gòu)成。那么,向文檔中添加一個 9 行 x 6 列的表格

      DocumentFormat.OpenXml.Wordprocessing.Table weekTable = body.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Table());

      #region 表格樣式

      TableProperties tabProps = new TableProperties(new TableBorders(

      new TopBorder { Val = new EnumValue(BorderValues.Single), Size = 4, Color = “4F81BD” },

      new BottomBorder

      {

      Val = new EnumValue(BorderValues.Single),

      Size = 4,

      Color = “4F81BD”

      },

      new LeftBorder

      {

      Val = new EnumValue(BorderValues.Single),

      Size = 4,

      Color = “4F81BD”

      },

      new RightBorder

      {

      Val = new EnumValue(BorderValues.Single),

      Size = 4,

      Color = “4F81BD”

      },

      new InsideHorizontalBorder

      {

      Val = new EnumValue(BorderValues.Single),

      Size = 4,

      Color = “4F81BD”

      },

      new InsideVerticalBorder

      {

      Val = new EnumValue(BorderValues.Single),

      Size = 4,

      Color = “4F81BD”

      }

      ));

      #endregion

      weekTable.AppendChild(tabProps);

      var tabWidth = new TableWidth { Width = “5000”, Type = TableWidthUnitValues.Pct };

      weekTable.AppendChild(tabWidth);

      if (headerArray != null && headerArray.Length > 0)

      {

      TableRow tabHeaderRow = weekTable.AppendChild(new TableRow());//設(shè)置列頭行

      foreach (var item in headerArray)

      {

      TableRowProperties tabRowProps = tabHeaderRow.AppendChild(new TableRowProperties(new TableRowHeight { Val = 600, HeightType = HeightRuleValues.Exact }));

      TableCell tabCell = tabHeaderRow.AppendChild(new TableCell());

      Paragraph tabCellPara = tabCell.AppendChild(new Paragraph());

      TableCellProperties tabCellProps = tabCell.AppendChild(new TableCellProperties(new TableCellWidth { Width = “10%”, Type = TableWidthUnitValues.Pct }));

      tabCellPara.AppendChild(new Run(new Text(item)));

      }

      }

      //如果要 Word 能夠正常打開文檔,每個 TableCell 至少需包含一個空段落才行。

      foreach (object[] rowArray in rowList)

      {

      TableRow tabRow = weekTable.AppendChild(new TableRow());

      TableRowProperties tabRowProps = tabRow.AppendChild(new TableRowProperties(new TableRowHeight { Val = 1500, HeightType = HeightRuleValues.Exact }));

      //列寬可以通過設(shè)置單元格的寬度實現(xiàn)

      foreach (object objCellValue in rowArray)

      {

      TableCell tabCell = tabRow.AppendChild(new TableCell());

      TableCellProperties tabCellProps;

      tabCellProps = tabCell.AppendChild(new TableCellProperties(new TableCellWidth { Width = “10%”, Type = TableWidthUnitValues.Pct }));

      if (objCellValue == null || objCellValue == DBNull.Value)

      {

      Paragraph tabCellPara = tabCell.AppendChild(new Paragraph());

      tabCellPara.AppendChild(new Run(new Text(“”)));//這里寫入單元格的值

      }

      if (objCellValue != null && objCellValue != DBNull.Value && objCellValue is string)

      {

      Paragraph tabCellPara = tabCell.AppendChild(new Paragraph());

      tabCellPara.AppendChild(new Run(new Text(objCellValue.ToString())));//這里寫入單元格的值

      }

      if (objCellValue != null && objCellValue is Stream)

      {

      string tempRelationId = Guid.NewGuid().ToString().ToUpper();

      AddImageToTableCell(tabCell, tempRelationId);

      }

      }

      }

      #endregion

      #endregion

      }

      Process.Start(fileName);

      }

      public static void AddImageToTableCell(TableCell tableCell, string relationshipId)

      {

      var element =

      new Drawing(

      new DocumentFormat.OpenXml.Drawing.Wordprocessing.Inline(

      new DocumentFormat.OpenXml.Drawing.Wordprocessing.Extent() { Cx = 990000L, Cy = 792000L },

      new DocumentFormat.OpenXml.Drawing.Wordprocessing.EffectExtent()

      {

      LeftEdge = 0L,

      TopEdge = 0L,

      RightEdge = 0L,

      BottomEdge = 0L

      },

      new DocumentFormat.OpenXml.Drawing.Wordprocessing.DocProperties()

      {

      Id = (UInt32Value)1U,

      Name = “Picture1”,

      Title = “圖片標(biāo)題

      },

      new DocumentFormat.OpenXml.Drawing.Wordprocessing.NonVisualGraphicFrameDrawingProperties(

      new DocumentFormat.OpenXml.Drawing.GraphicFrameLocks() { NoChangeAspect = true }),

      new DocumentFormat.OpenXml.Drawing.Graphic(

      new DocumentFormat.OpenXml.Drawing.GraphicData(

      new DocumentFormat.OpenXml.Drawing.Pictures.Picture(

      new DocumentFormat.OpenXml.Drawing.Pictures.NonVisualPictureProperties(

      new DocumentFormat.OpenXml.Drawing.Pictures.NonVisualDrawingProperties()

      {

      Id = (UInt32Value)0U,

      Name = “New Bitmap Image.jpg”

      },

      new DocumentFormat.OpenXml.Drawing.Pictures.NonVisualPictureDrawingProperties()),

      new DocumentFormat.OpenXml.Drawing.Pictures.BlipFill(

      new DocumentFormat.OpenXml.Drawing.Blip(

      new DocumentFormat.OpenXml.Drawing.BlipExtensionList(

      new DocumentFormat.OpenXml.Drawing.BlipExtension()

      {

      Uri =

      “{28A0092B-C50C-407E-A947-70E740481C1C}”

      })

      )

      {

      Embed = relationshipId,

      CompressionState =

      DocumentFormat.OpenXml.Drawing.BlipCompressionValues.Print

      },

      new DocumentFormat.OpenXml.Drawing.Stretch(

      new DocumentFormat.OpenXml.Drawing.FillRectangle())),

      new DocumentFormat.OpenXml.Drawing.Pictures.ShapeProperties(

      new DocumentFormat.OpenXml.Drawing.Transform2D(

      new DocumentFormat.OpenXml.Drawing.Offset() { X = 0L, Y = 0L },

      new DocumentFormat.OpenXml.Drawing.Extents() { Cx = 990000L, Cy = 792000L }),

      new DocumentFormat.OpenXml.Drawing.PresetGeometry(

      new DocumentFormat.OpenXml.Drawing.AdjustValueList()

      )

      { Preset = DocumentFormat.OpenXml.Drawing.ShapeTypeValues.Rectangle }))

      )

      { Uri = “http://schemas.openxmlformats.org/drawingml/2006/picture” })

      )

      {

      DistanceFromTop = (UInt32Value)0U,

      DistanceFromBottom = (UInt32Value)0U,

      DistanceFromLeft = (UInt32Value)0U,

      DistanceFromRight = (UInt32Value)0U,

      EditId = “50D07946”

      });

      // Append the reference to body, the element should be in a Run.

      tableCell.AppendChild(new Paragraph(new Run(element)));

      }

      鄭重聲明:本文內(nèi)容及圖片均整理自互聯(lián)網(wǎng),不代表本站立場,版權(quán)歸原作者所有,如有侵權(quán)請聯(lián)系管理員(admin#wlmqw.com)刪除。
      (0)
      用戶投稿
      上一篇 2022年6月13日 12:09
      下一篇 2022年6月13日 12:10

      相關(guān)推薦

      • 國防科大“天河”超算斬獲兩項世界第一

        湖南日報6月24日訊(全媒體記者 施泉江 通訊員 高莉華)近日,記者從國防科技大學(xué)計算機學(xué)院獲悉,在第24屆國際超算排名Graph500發(fā)布的榜單中,由該院研制并部署在國家超級計算…

        2022年6月25日
      • 再獲四項發(fā)明專利!精準(zhǔn)捕捉進球瞬間

        近日,由新華智云自主研發(fā)的四項發(fā)明專利,成功獲得國家知識產(chǎn)權(quán)局授權(quán)。 它們分別是:“足球射門時刻的識別方法、裝置、存儲介質(zhì)及計算機設(shè)備”、“一種基于人工智能的籃球進球片段AB隊自動…

        2022年6月20日
      • 介紹seo建站的6個技巧(seo建站的技巧有哪些)

        網(wǎng)站對于企業(yè)的重要性不言而喻,若是沒有網(wǎng)站,企業(yè)的互聯(lián)網(wǎng)宣傳、客戶溝通、引流拉新可能都成問題。不過,只有網(wǎng)站是不夠的,你還需要做好SEO優(yōu)化建站,讓網(wǎng)站有個好的排名。那么公司建站該…

        2022年11月5日
      • 第五屆數(shù)字中國建設(shè)成果展開幕

        作為數(shù)字中國建設(shè)峰會的重要組成部分,第五屆數(shù)字中國建設(shè)成果展覽會22日在海峽國際會展中心開幕,展期共5天,將于26日閉幕。 本次展覽位于海峽國際會展中心5號、6號、7號、8號、10…

        2022年8月1日
      • 人工智能技術(shù)對兒童帶來哪些影響?

        人工智能技術(shù)被嵌入到玩具、網(wǎng)絡(luò)應(yīng)用或視頻游戲中;人工智能算法向孩子們推薦下一個要看的視頻、要看的新聞、要聽的音樂以及建議與誰成為朋友……當(dāng)前,人工智能系統(tǒng)正在從根本上改變世界并影響…

        2022年6月22日
      • 區(qū)塊鏈“潛入”司法場景

        本報記者 鄭瑜 北京報道 區(qū)塊鏈作為核心自主創(chuàng)新的重要突破口,與數(shù)字社會的融合正在不斷加快,尤其是在司法應(yīng)用領(lǐng)域的創(chuàng)新實踐正不斷涌現(xiàn)。 日前,江蘇省高級人民法院表示,江蘇法院區(qū)塊鏈…

        2022年6月13日
      • Git 重命名遠(yuǎn)程分支 – 操作不規(guī)范,親人兩行淚

        TIPS:以下代碼示例語言為Go 問題描述 小A和我并行開發(fā),他在優(yōu)化之前的代碼邏輯,我在開發(fā)新功能。 小A在我之前把代碼提交到了測試分支,我想提交我的新功能代碼到測試分支時發(fā)現(xiàn)巨…

        2022年7月3日
      • 重磅!DIY的Prometheus主備方案,全網(wǎng)唯一 生產(chǎn)未上,測試先行

        寫在開篇 關(guān)于prometheus的高可用方案,經(jīng)過筆者不斷的研究、對比、和搜索,發(fā)現(xiàn)不管是官方、還是各大搜索引擎搜索出來的方案,都不符合筆者的需求。因此,筆者自己設(shè)計了一套pro…

        2022年6月13日
      • 地產(chǎn)企業(yè)數(shù)字化轉(zhuǎn)型想要把握時代機遇

        隨著近年物聯(lián)網(wǎng)、人工智能、區(qū)塊鏈等新技術(shù)的發(fā)展,全球數(shù)字化浪潮已催生出了數(shù)字 經(jīng)濟時代,而在房地產(chǎn)行業(yè)自進入白銀時代以來,競爭日趨激烈,眾多房地產(chǎn)企業(yè)都面 臨著提質(zhì)增效、轉(zhuǎn)型變革的…

        2022年6月13日
      • 《黑貓奇聞社》:以為是顏值游戲,沒想到推理也能這么“專業(yè)”?

        對于很多游戲愛好者來說,挑選游戲的第一準(zhǔn)則就是看畫面夠不夠驚艷,人物顏值夠不夠高,畢竟愛美之心人皆有之嘛,小編也不例外~所以當(dāng)有著“顏狗盛宴”之稱的《黑貓奇聞社》開啟晨曦測試的時候…

        2022年8月7日

      聯(lián)系我們

      聯(lián)系郵箱:admin#wlmqw.com
      工作時間:周一至周五,10:30-18:30,節(jié)假日休息