当前位置: 首页>>代码示例>>C#>>正文


C# Cell.AppendChild方法代码示例

本文整理汇总了C#中Cell.AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C# Cell.AppendChild方法的具体用法?C# Cell.AppendChild怎么用?C# Cell.AppendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cell的用法示例。


在下文中一共展示了Cell.AppendChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createTextCell

        public static Cell createTextCell(
            int columnIndex,
            int rowIndex,
            object cellValue)
        {
            Cell cell = new Cell();

            cell.DataType = CellValues.InlineString;
            cell.CellReference = getColumnName(columnIndex) + rowIndex;

            InlineString inlineString = new InlineString();
            DocumentFormat.OpenXml.Spreadsheet.Text t = new DocumentFormat.OpenXml.Spreadsheet.Text();

            t.Text = cellValue.ToString();
            inlineString.AppendChild(t);
            cell.AppendChild(inlineString);

            return cell;
        }
开发者ID:mukeshdepani,项目名称:ParaRD,代码行数:19,代码来源:Common.cs

示例2: CreateNewRow

        private static Row CreateNewRow(int rowIndex, params string[] data)
        {
            // New Row
            Row row = new Row { RowIndex = (UInt32)rowIndex };

            for (int i = 0; i < data.Length; i++)
            {
                // A = 65 for the first column, B = 66, C = 67...
                string column = ((char) (65 + i)).ToString();

                // New Cell
                Cell cell = new Cell
                                {
                                    DataType = CellValues.InlineString,
                                    CellReference = column + rowIndex
                                };

                // Create Text object
                Text t = new Text {Text = data[i]};

                // Append Text to InlineString object
                InlineString inlineString = new InlineString();
                inlineString.AppendChild(t);

                // Append InlineString to Cell
                cell.AppendChild(inlineString);

                // Append Cell to Row
                row.AppendChild(cell);
            }
            return row;
        }
开发者ID:stevenh77,项目名称:CreatingExcelFile,代码行数:32,代码来源:Program.cs

示例3: CreateTextCell

		private Cell CreateTextCell(string header, UInt32 index, string text)
		{
			var cell = new Cell
			{
				DataType = CellValues.InlineString,
				CellReference = header + index
			};

			var istring = new InlineString();
			var t = new Text { Text = text };
			istring.AppendChild(t);
			cell.AppendChild(istring);
			return cell;
		}
开发者ID:slaq777,项目名称:lmsystem,代码行数:14,代码来源:SLExcelWriter.cs

示例4: createTextCell

        private static Cell createTextCell(int columnIndex, int rowIndex, string cellValue)
        {
            Cell cell = new Cell();

              cell.DataType = CellValues.InlineString;
              //cell.CellReference = getColumnName(columnIndex) + rowIndex;

              InlineString inlineString = new InlineString();
              Text t = new Text(cellValue);
              inlineString.AppendChild(t);
              cell.AppendChild(inlineString);

              return cell;
        }
开发者ID:AirVan21,项目名称:tools,代码行数:14,代码来源:Integrator.cs

示例5: Run

        public static void Run()
        {
            // ExStart:InsertTableDirectly
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithTables();

            Document doc = new Document();
            // We start by creating the table object. Note how we must pass the document object
            // To the constructor of each node. This is because every node we create must belong
            // To some document.
            Table table = new Table(doc);
            // Add the table to the document.
            doc.FirstSection.Body.AppendChild(table);

            // Here we could call EnsureMinimum to create the rows and cells for us. This method is used
            // To ensure that the specified node is valid, in this case a valid table should have at least one
            // Row and one cell, therefore this method creates them for us.

            // Instead we will handle creating the row and table ourselves. This would be the best way to do this
            // If we were creating a table inside an algorthim for example.
            Row row = new Row(doc);
            row.RowFormat.AllowBreakAcrossPages = true;
            table.AppendChild(row);

            // We can now apply any auto fit settings.
            table.AutoFit(AutoFitBehavior.FixedColumnWidths);

            // Create a cell and add it to the row
            Cell cell = new Cell(doc);
            cell.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue;
            cell.CellFormat.Width = 80;

            // Add a paragraph to the cell as well as a new run with some text.
            cell.AppendChild(new Paragraph(doc));
            cell.FirstParagraph.AppendChild(new Run(doc, "Row 1, Cell 1 Text"));

            // Add the cell to the row.
            row.AppendChild(cell);

            // We would then repeat the process for the other cells and rows in the table.
            // We can also speed things up by cloning existing cells and rows.
            row.AppendChild(cell.Clone(false));
            row.LastCell.AppendChild(new Paragraph(doc));
            row.LastCell.FirstParagraph.AppendChild(new Run(doc, "Row 1, Cell 2 Text"));
            dataDir = dataDir + "Table.InsertTableUsingNodes_out.doc";
            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:InsertTableDirectly
            Console.WriteLine("\nTable using notes inserted successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:50,代码来源:InsertTableDirectly.cs

示例6: CreateTextCell

        private Cell CreateTextCell(string header, string text, int index)
        {
            // New Cell
            Cell cell = new Cell { DataType = CellValues.InlineString, CellReference = header + index };

            // Create Text object
            Text t = new Text { Text = text };

            // Append Text to InlineString object
            InlineString inlineString = new InlineString();
            inlineString.AppendChild(t);

            // Append InlineString to Cell
            cell.AppendChild(inlineString);

            return cell;
        }
开发者ID:arnabknd4,项目名称:scs2300915,代码行数:17,代码来源:ImportOwner.cs

示例7: SetDataToExcel


//.........这里部分代码省略.........
                    }

                    WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheets.First().Id);

                    SheetData sheetData = worksheetPart.Worksheet.GetFirstChild<SheetData>();

                    //sheetData.RemoveAllChildren<Row>();

                    //SharedStringTablePart shareStringTablePart = document.WorkbookPart.SharedStringTablePart;

                    int lastRowIndex = sheetData.ChildElements.Count;
                    int k = 0; //step in intro
                    for (int i = lastRowIndex; i < data.Rows.Count + 4 + lastRowIndex + intro.Length; i++) // +1 for the header label, + 2 for spacing row, + 1 for title
                    {
                        DataRow dataRow = null;

                        if (i > lastRowIndex + 3 + intro.Length)
                        {
                            dataRow = data.Rows[i - 4 - lastRowIndex - intro.Length];
                        }
                        Row aRow = new Row();
                        aRow.RowIndex = (UInt32)i + 1;

                        bool isRowEnd = false;//Fix the excel expand

                        for (int j = 0; j < data.Columns.Count; j++)
                        {
                            if (isRowEnd)
                            {
                                break;//Fix the excel expand
                            }
                            Cell cell = new Cell();
                            cell.DataType = CellValues.InlineString;

                            cell.CellReference = GetAlpha(j + 1) + (i + 1);

                            InlineString inlineString = new InlineString();

                            Text t = new Text();

                            if (i <= lastRowIndex + intro.Length - 1)//Intro
                            {
                                if (j == 0)
                                {
                                    t.Text = intro[k];
                                    k++;
                                    cell.StyleIndex = (UInt32Value)3U;
                                    isRowEnd = true;
                                }
                            }
                            else if (i == lastRowIndex + intro.Length + 1)//Title
                            {
                                if (j == 0)
                                {
                                    t.Text = title;
                                    cell.StyleIndex = (UInt32Value)4U;
                                    isRowEnd = true;
                                }

                            }
                            else if (i == lastRowIndex + 3 + intro.Length)//Header
                            {
                                t.Text = data.Columns[j].ToString();
                                cell.StyleIndex = (UInt32Value)1U;
                            }
                            else
                            {
                                if (i != intro.Length + lastRowIndex && i != intro.Length + lastRowIndex + 2)//Null spacing row
                                    t.Text = dataRow[j].ToString();//Data row
                            }


                            inlineString.AppendChild(t);

                            cell.AppendChild(inlineString);
                            aRow.AppendChild(cell);
                        }

                        sheetData.AppendChild(aRow);
                    }

                    System.Xml.XmlWriter test = System.Xml.XmlWriter.Create("Test.xml");
                    worksheetPart.Worksheet.WriteTo(test);
                    test.Close();

                    worksheetPart.Worksheet.Save();

                    document.WorkbookPart.Workbook.Save();
                    document.Close();
                }

            }
            catch (Exception e)
            {
                SystemHelper.LogEntry(string.Format("Error occurs on method {0} - Message {1}", "GetDataFromExcel", e.Message));
                return false;
            }
            return true;

        }
开发者ID:tiemptit,项目名称:travelh2v,代码行数:101,代码来源:ExcelHelper.cs

示例8: CreateTextCell

 Cell CreateTextCell(string header, string text, int index)
 {
     //Create a new inline string cell.
     Cell c = new Cell();
     c.DataType = CellValues.InlineString;
     c.CellReference = header + index;
     //Add text to the text cell.
     InlineString inlineString = new InlineString();
     Text t = new Text();
     t.Text = text;
     inlineString.AppendChild(t);
     c.AppendChild(inlineString);
     return c;
 }
开发者ID:tiemptit,项目名称:travelh2v,代码行数:14,代码来源:ExcelHelper.cs

示例9: createTextCell

        private Cell createTextCell(int columnIndex, int rowIndex, object cellValue)
        {
            Cell cell = new Cell();

            cell.DataType = CellValues.InlineString;
            cell.CellReference = getColumnName(columnIndex) + rowIndex;

            InlineString inlineString = new InlineString();
            Text t = new Text();

            t.Text = cellValue.ToString();
            inlineString.AppendChild(t);
            cell.AppendChild(inlineString);

            return cell;
        }
开发者ID:MGGROUP,项目名称:BASICA,代码行数:16,代码来源:ReportesMen.aspx.cs

示例10: CreateTable

        /// <summary>
        /// Creates a new table in the document with the given dimensions and text in each cell.
        /// </summary>
        private Table CreateTable(Document doc, int rowCount, int cellCount, string cellText)
        {
            Table table = new Table(doc);

            // Create the specified number of rows.
            for (int rowId = 1; rowId <= rowCount; rowId++)
            {
                Row row = new Row(doc);
                table.AppendChild(row);

                // Create the specified number of cells for each row.
                for (int cellId = 1; cellId <= cellCount; cellId++)
                {
                    Cell cell = new Cell(doc);
                    row.AppendChild(cell);
                    // Add a blank paragraph to the cell.
                    cell.AppendChild(new Paragraph(doc));

                    // Add the text.
                    cell.FirstParagraph.AppendChild(new Run(doc, cellText));
                }
            }

            return table;
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:28,代码来源:ExTable.cs

示例11: InsertTableUsingNodeConstructors

        public void InsertTableUsingNodeConstructors()
        {
            //ExStart
            //ExFor:Table
            //ExFor:Row
            //ExFor:Row.RowFormat
            //ExFor:RowFormat
            //ExFor:Cell
            //ExFor:Cell.CellFormat
            //ExFor:CellFormat
            //ExFor:CellFormat.Shading
            //ExFor:Cell.FirstParagraph
            //ExId:InsertTableUsingNodeConstructors
            //ExSummary:Shows how to insert a table using the constructors of nodes.
            Document doc = new Document();

            // We start by creating the table object. Note how we must pass the document object
            // to the constructor of each node. This is because every node we create must belong
            // to some document.
            Table table = new Table(doc);
            // Add the table to the document.
            doc.FirstSection.Body.AppendChild(table);

            // Here we could call EnsureMinimum to create the rows and cells for us. This method is used
            // to ensure that the specified node is valid, in this case a valid table should have at least one
            // row and one cell, therefore this method creates them for us.

            // Instead we will handle creating the row and table ourselves. This would be the best way to do this
            // if we were creating a table inside an algorthim for example.
            Row row = new Row(doc);
            row.RowFormat.AllowBreakAcrossPages = true;
            table.AppendChild(row);

            // We can now apply any auto fit settings.
            table.AutoFit(AutoFitBehavior.FixedColumnWidths);

            // Create a cell and add it to the row
            Cell cell = new Cell(doc);
            cell.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue;
            cell.CellFormat.Width = 80;
            
            // Add a paragraph to the cell as well as a new run with some text.
            cell.AppendChild(new Paragraph(doc));
            cell.FirstParagraph.AppendChild(new Run(doc, "Row 1, Cell 1 Text"));

            // Add the cell to the row.
            row.AppendChild(cell);

            // We would then repeat the process for the other cells and rows in the table.
            // We can also speed things up by cloning existing cells and rows.
            row.AppendChild(cell.Clone(false));
            row.LastCell.AppendChild(new Paragraph(doc));
            row.LastCell.FirstParagraph.AppendChild(new Run(doc, "Row 1, Cell 2 Text"));

            doc.Save(MyDir + @"\Artifacts\Table.InsertTableUsingNodes.doc");
            //ExEnd

            Assert.AreEqual(1, doc.GetChildNodes(NodeType.Table, true).Count);
            Assert.AreEqual(1, doc.GetChildNodes(NodeType.Row, true).Count);
            Assert.AreEqual(2, doc.GetChildNodes(NodeType.Cell, true).Count);
            Assert.AreEqual("Row 1, Cell 1 Text\r\nRow 1, Cell 2 Text", doc.FirstSection.Body.Tables[0].ToString(SaveFormat.Text).Trim());
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:62,代码来源:ExTable.cs

示例12: VerticallyMergeCells

        /// <summary>
        /// Aspose Word 垂直合併上至下(單一)
        /// </summary>
        /// <param name="top"></param>
        /// <param name="bottom"></param>
        public static void VerticallyMergeCells(Cell top, Cell bottom)
        {
            top.CellFormat.VerticalMerge = CellMerge.First;

            foreach (Node child in bottom.ChildNodes)
                top.AppendChild(child);

            bottom.CellFormat.VerticalMerge = CellMerge.Previous;

            if (top.HasChildNodes)
                top.RemoveChild(top.LastChild);
        }
开发者ID:ChunTaiChen,项目名称:Counsel_System,代码行数:17,代码来源:Utility.cs

示例13: HorizontallyMergeCells

        /// <summary>
        /// 處理 Aspose Word 水平合併(左至右)(單一)
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        public static void HorizontallyMergeCells(Cell left, Cell right)
        {
            left.CellFormat.HorizontalMerge = CellMerge.First;

            foreach (Node child in right.ChildNodes)
                left.AppendChild(child);

            right.CellFormat.HorizontalMerge = CellMerge.Previous;
            
            // 處理移除合併後有 \r\n 問題
            if (left.HasChildNodes)
                left.RemoveChild(left.LastChild);        
        }
开发者ID:ChunTaiChen,项目名称:Counsel_System,代码行数:18,代码来源:Utility.cs

示例14: createContentRow

        private Row createContentRow(int index, string firstColVal, IEnumerable<double>values)
        {
            Row r = new Row();
            r.RowIndex = (UInt32)index;
            char col = 'B';

            Cell cell = createTextCell("A", firstColVal, index);
            r.AppendChild(cell);

            //Create cells that contain data
            foreach (double val in values) {
                Cell c = new Cell();
                c.CellReference = col.ToString() + index;
                CellValue v = new CellValue();
                v.Text = val.ToString();

                c.AppendChild(v);
                r.AppendChild(c);
            }
            return r;
        }
开发者ID:garsiden,项目名称:Report-Generator,代码行数:21,代码来源:GraphData.cs

示例15: buildRowFromPhoneLog

        protected Row buildRowFromPhoneLog(int index, Models.PhoneLog log)
        {
            // New Row
            Row row = new Row();
            row.RowIndex = (UInt32)index;

            // New Cell
            Cell cell = new Cell();
            cell.DataType = CellValues.InlineString;
            // Column A1, 2, 3 ... and so on
            //cell.CellReference = "A" + index;

            Text t = new Text();
            t.Text = log.Id.ToString();
            InlineString inlineString = new InlineString();
            inlineString.AppendChild(t);
            cell.AppendChild(inlineString);
            row.AppendChild(cell);

            cell = new Cell();
            cell.DataType = CellValues.InlineString;
            t = new Text();
            t.Text = log.CallerName;
            // Append Text to InlineString object
            inlineString = new InlineString();
            inlineString.AppendChild(t);
            cell.AppendChild(inlineString);
            row.AppendChild(cell);

            cell = new Cell();
            cell.DataType = CellValues.InlineString;
            t = new Text();
            t.Text = log.PhoneNumber;
            // Append Text to InlineString object
            inlineString = new InlineString();
            inlineString.AppendChild(t);
            cell.AppendChild(inlineString);
            row.AppendChild(cell);

            cell = new Cell();
            cell.DataType = CellValues.InlineString;
            t = new Text();
            t.Text = log.CallType;
            // Append Text to InlineString object
            inlineString = new InlineString();
            inlineString.AppendChild(t);
            cell.AppendChild(inlineString);
            row.AppendChild(cell);

            cell = new Cell();
            cell.DataType = CellValues.InlineString;
            t = new Text();
            t.Text = log.Message;
            // Append Text to InlineString object
            inlineString = new InlineString();
            inlineString.AppendChild(t);
            cell.AppendChild(inlineString);
            row.AppendChild(cell);

            cell = new Cell();
            cell.DataType = CellValues.InlineString;
            t = new Text();
            t.Text = log.EmployeeEmail;
            // Append Text to InlineString object
            inlineString = new InlineString();
            inlineString.AppendChild(t);
            cell.AppendChild(inlineString);
            row.AppendChild(cell);

            cell = new Cell();
            cell.DataType = CellValues.InlineString;
            t = new Text();
            t.Text = log.CallDate.Value.ToShortDateString();
            // Append Text to InlineString object
            inlineString = new InlineString();
            inlineString.AppendChild(t);
            cell.AppendChild(inlineString);
            row.AppendChild(cell);

            cell = new Cell();
            cell.DataType = CellValues.InlineString;
            t = new Text();
            t.Text = log.FollowedUp.Value.ToString();
            // Append Text to InlineString object
            inlineString = new InlineString();
            inlineString.AppendChild(t);
            cell.AppendChild(inlineString);
            row.AppendChild(cell);

            return row;
        }
开发者ID:rgarbi,项目名称:RosedalePhoneLog,代码行数:91,代码来源:ReportResultsPage.aspx.cs


注:本文中的Cell.AppendChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。