• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# NPOI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NPOI的典型用法代码示例。如果您正苦于以下问题:C# NPOI类的具体用法?C# NPOI怎么用?C# NPOI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NPOI类属于命名空间,在下文中一共展示了NPOI类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: setValue

 private static void setValue(NPOI.SS.UserModel.ISheet sheet, int rowIndex, int colIndex, double value)
 {
     IRow row = sheet.GetRow(rowIndex);
     if (row == null)
     {
         row = sheet.CreateRow(rowIndex);
     }
     row.CreateCell(colIndex).SetCellValue(value);
 }
开发者ID:age-soft,项目名称:npoi,代码行数:9,代码来源:TestHSSFFormulaEvaluator.cs


示例2: CreateCell

        public static void CreateCell(NPOI.SS.UserModel.IRow row, int index, object value, NPOI.SS.UserModel.ICellStyle cellStyle)
        {
            var cell = row.CreateCell(index);
            if (value is decimal)
                cell.SetCellValue((double)((decimal)value));
            else
                if (value is int)
                    cell.SetCellValue((int)value);
                else
                    cell.SetCellValue((string)value);

            cell.CellStyle = cellStyle;
        }
开发者ID:HansonDodge,项目名称:DirtyGirl,代码行数:13,代码来源:ReportUtilities.cs


示例3: Serialize

 public override void Serialize(NPOI.Util.IO.LittleEndianOutput out1)
 {
     out1.WriteShort(mdTopLt);
     out1.WriteShort(mdBotRt);
     out1.WriteShort(x1);
     out1.WriteShort(0);
     out1.WriteShort(y1);
     out1.WriteShort(0);
     out1.WriteShort(x2);
     out1.WriteShort(0);
     out1.WriteShort(y2);
     out1.WriteShort(0);
 }
开发者ID:uwitec,项目名称:web-mvc-logistics,代码行数:13,代码来源:PosRecord.cs


示例4: SetBorderBottom

 //[Obsolete]
 //public static void SetBorderBottom(NPOI.SS.UserModel.CellBorderType border, Region region, HSSFSheet sheet,
 //        HSSFWorkbook workbook)
 //{
 //    SetBorderBottom(border, toCRA(region), sheet, workbook);
 //}
 /// <summary>
 /// Sets the borderBottom attribute of the HSSFRegionUtil object
 /// </summary>
 /// <param name="border">The new border</param>
 /// <param name="region">The region that should have the border</param>
 /// <param name="sheet">The sheet that the region is on.</param>
 /// <param name="workbook">The workbook that the region is on.</param>
 public static void SetBorderBottom(NPOI.SS.UserModel.CellBorderType border, CellRangeAddress region, HSSFSheet sheet,
         HSSFWorkbook workbook)
 {
     int colStart = region.FirstColumn;
     int colEnd = region.LastColumn;
     int rowIndex = region.LastRow;
     CellPropertySetter cps = new CellPropertySetter(workbook, HSSFCellUtil.BORDER_BOTTOM, (int)border);
     NPOI.SS.UserModel.Row row = HSSFCellUtil.GetRow(rowIndex, sheet);
     for (int i = colStart; i <= colEnd; i++)
     {
         cps.SetProperty(row, i);
     }
 }
开发者ID:babywzazy,项目名称:Server,代码行数:26,代码来源:HSSFRegionUtil.cs


示例5: CreatePageMaster

        protected String CreatePageMaster(NPOI.HWPF.UserModel.Section section, String type, int sectionIndex)
        {
            float height = section.PageHeight / WordToFoUtils.TWIPS_PER_INCH;
            float width = section.PageWidth / WordToFoUtils.TWIPS_PER_INCH;
            float leftMargin = section.MarginLeft
                    / WordToFoUtils.TWIPS_PER_INCH;
            float rightMargin = section.MarginRight
                    / WordToFoUtils.TWIPS_PER_INCH;
            float topMargin = section.MarginTop / WordToFoUtils.TWIPS_PER_INCH;
            float bottomMargin = section.MarginBottom
                    / WordToFoUtils.TWIPS_PER_INCH;

            // add these to the header
            String pageMasterName = type + "-page" + sectionIndex;

            XmlElement pageMaster = foDocumentFacade.AddSimplePageMaster(pageMasterName);
            pageMaster.SetAttribute("page-height", height + "in");
            pageMaster.SetAttribute("page-width", width + "in");

            XmlElement regionBody = foDocumentFacade.AddRegionBody(pageMaster);
            regionBody.SetAttribute("margin", topMargin + "in " + rightMargin
                    + "in " + bottomMargin + "in " + leftMargin + "in");

            /*
             * 6.4.14 fo:region-body
             * 
             * The values of the padding and border-width traits must be "0".
             */
            // WordToFoUtils.setBorder(regionBody, sep.getBrcTop(), "top");
            // WordToFoUtils.setBorder(regionBody, sep.getBrcBottom(), "bottom");
            // WordToFoUtils.setBorder(regionBody, sep.getBrcLeft(), "left");
            // WordToFoUtils.setBorder(regionBody, sep.getBrcRight(), "right");

            if (section.NumColumns > 1)
            {
                regionBody.SetAttribute("column-count", "" + (section.NumColumns));
                if (section.IsColumnsEvenlySpaced)
                {
                    float distance = section.DistanceBetweenColumns / WordToFoUtils.TWIPS_PER_INCH;
                    regionBody.SetAttribute("column-gap", distance + "in");
                }
                else
                {
                    regionBody.SetAttribute("column-gap", "0.25in");
                }
            }

            return pageMasterName;
        }
开发者ID:89sos98,项目名称:npoi,代码行数:49,代码来源:WordToFoConverter.cs


示例6: Serialize

 public void Serialize(NPOI.Util.IO.LittleEndianOutput out1)
 {
     out1.WriteShort(FirstRow);
     out1.WriteShort(LastRow);
     out1.WriteByte(FirstColumn);
     out1.WriteByte(LastColumn);
 }
开发者ID:babywzazy,项目名称:Server,代码行数:7,代码来源:CellRangeAddress8Bit.cs


示例7: ArrayRecord

 public ArrayRecord(NPOI.SS.Formula.Formula formula, CellRangeAddress8Bit range)
     : base(range)
 {
     _options = 0; //YK: Excel 2007 leaves this field unset
     _field3notUsed = 0;
     _formula = formula;
 }
开发者ID:babywzazy,项目名称:Server,代码行数:7,代码来源:ArrayRecord.cs


示例8: Slide

	private Notes _notes; // usermodel needs to Set this

	/**
	 * Constructs a Slide from the Slide record, and the SlideAtomsSet
	 *  Containing the text.
	 * Initialises TextRuns, to provide easier access to the text
	 *
	 * @param slide the Slide record we're based on
	 * @param notes the Notes sheet attached to us
	 * @param atomSet the SlideAtomsSet to Get the text from
	 */
	public Slide(NPOI.HSLF.record.Slide slide, Notes notes, SlideAtomsSet atomSet, int slideIdentifier, int slideNumber) {
        base(slide, slideIdentifier);

		_notes = notes;
		_atomSet = atomSet;
		_slideNo = slideNumber;

 		// Grab the TextRuns from the PPDrawing
		TextRun[] _otherRuns = FindTextRuns(getPPDrawing());

		// For the text coming in from the SlideAtomsSet:
		// Build up TextRuns from pairs of TextHeaderAtom and
		//  one of TextBytesAtom or TextCharsAtom
		Vector textRuns = new Vector();
		if(_atomSet != null) {
			FindTextRuns(_atomSet.GetSlideRecords(),textRuns);
		} else {
			// No text on the slide, must just be pictures
		}

		// Build an array, more useful than a vector
		_Runs = new TextRun[textRuns.Count+_otherRuns.Length];
		// Grab text from SlideListWithTexts entries
		int i=0;
		for(i=0; i<textRuns.Count; i++) {
			_Runs[i] = (TextRun)textRuns.Get(i);
            _Runs[i].SetSheet(this);
		}
		// Grab text from slide's PPDrawing
		for(int k=0; k<_otherRuns.Length; i++, k++) {
			_Runs[i] = _otherRuns[k];
            _Runs[i].SetSheet(this);
		}
	}
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:45,代码来源:Slide.cs


示例9: Create

 public static HSSFEvaluationWorkbook Create(NPOI.SS.UserModel.IWorkbook book)
 {
     if (book == null)
     {
         return null;
     }
     return new HSSFEvaluationWorkbook((HSSFWorkbook)book);
 }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:8,代码来源:HSSFEvaluationWorkbook.cs


示例10: Serialize

 public override void Serialize(NPOI.Util.ILittleEndianOutput out1)
 {
     out1.WriteInt(field_1_rgbFore);
     out1.WriteInt(field_2_rgbBack);
     out1.WriteShort(field_3_imk);
     out1.WriteShort(field_4_flag);
     out1.WriteShort(field_5_icvFore);
     out1.WriteShort(field_6_icvBack);
     out1.WriteInt(field_7_miSize);
 }
开发者ID:hanwangkun,项目名称:npoi,代码行数:10,代码来源:MarkerFormatRecord.cs


示例11: Serialize

 public override void Serialize(NPOI.Util.ILittleEndianOutput out1)
 {
     out1.WriteShort(field_1_anRot);
     out1.WriteShort(field_2_anElev);
     out1.WriteShort(field_3_pcDist);
     out1.WriteShort(field_4_pcHeight);
     out1.WriteShort(field_5_pcDepth);
     out1.WriteShort(field_6_pcGap);
     out1.WriteShort(field_7_option);
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:10,代码来源:Chart3dRecord.cs


示例12: Notes

  /**
   * Constructs a Notes Sheet from the given Notes record.
   * Initialises TextRuns, to provide easier access to the text
   *
   * @param notes the Notes record to read from
   */
  public Notes (NPOI.HSLF.record.Notes notes) {
      base(notes, notes.GetNotesAtom().GetSlideID());

	// Now, build up TextRuns from pairs of TextHeaderAtom and
	//  one of TextBytesAtom or TextCharsAtom, found inside
	//  EscherTextboxWrapper's in the PPDrawing
	_Runs = FindTextRuns(getPPDrawing());

	// Set the sheet on each TextRun
	for (int i = 0; i < _Runs.Length; i++)
		_Runs[i].SetSheet(this);
  }
开发者ID:89sos98,项目名称:npoi,代码行数:18,代码来源:Notes.cs


示例13: Add

 private static void Add(Hashtable m, OperationPtg ptgKey,
     NPOI.SS.Formula.Functions.Function instance)
 {
     // make sure ptg has single private constructor because map lookups assume singleton keys
     ConstructorInfo[] cc = ptgKey.GetType().GetConstructors();
     if (cc.Length > 1 || (cc.Length > 0 && !cc[0].IsPrivate))
     {
         throw new Exception("Failed to verify instance ("
                 + ptgKey.GetType().Name + ") is a singleton.");
     }
     m[ptgKey] = instance;
 }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:12,代码来源:OperationEvaluatorFactory.cs


示例14: NPOIWorksheet

 public NPOIWorksheet(NPOI.SS.UserModel.IWorkbook npoiWorkbook, ISheet npoiWorksheet,
                      IWorkbook workbook, DataTable table, String sheetName,
                      Int32 startRow = 1, Int32 startColumn = 1)
 {
     _wb = npoiWorkbook;
     _ws = npoiWorksheet;
     Workbook = workbook;
     Table = table;
     Name = sheetName;
     StartRow = startRow;
     StartColumn = startColumn;
 }
开发者ID:stevedubyo,项目名称:dubexcel,代码行数:12,代码来源:NPOIWorksheet.cs


示例15: ExportReportHeader

        public static void ExportReportHeader(string title, NPOI.SS.UserModel.ISheet sheet, StyleContainer allStyles, ref int rowNumber)
        {
            var row = sheet.CreateRow(rowNumber++);
            row.HeightInPoints = 27;
            var titleCell = row.CreateCell(0);
            titleCell.SetCellValue(title);
            titleCell.CellStyle = allStyles.HeaderStyle;

            titleCell.CellStyle.WrapText = true;

            var titleMerge = new NPOI.SS.Util.CellRangeAddress(0, 0, 0, 7);
            sheet.AddMergedRegion(titleMerge);

            row = sheet.CreateRow(rowNumber++);
        }
开发者ID:HansonDodge,项目名称:DirtyGirl,代码行数:15,代码来源:ReportUtilities.cs


示例16: GetAnchorHeightInPoints

        /// <summary>
        /// Calculates the height of a client anchor in points.
        /// </summary>
        /// <param name="sheet">the sheet the anchor will be attached to</param>
        /// <returns>the shape height.</returns>     
        public float GetAnchorHeightInPoints(NPOI.SS.UserModel.ISheet sheet)
        {
            int y1 = Dy1;
            int y2 = Dy2;
            int row1 = Math.Min(Row1, Row2);
            int row2 = Math.Max(Row1, Row2);

            float points = 0;
            if (row1 == row2)
            {
                points = ((y2 - y1) / 256.0f) * GetRowHeightInPoints(sheet, row2);
            }
            else
            {
                points += ((256.0f - y1) / 256.0f) * GetRowHeightInPoints(sheet, row1);
                for (int i = row1 + 1; i < row2; i++)
                {
                    points += GetRowHeightInPoints(sheet, i);
                }
                points += (y2 / 256.0f) * GetRowHeightInPoints(sheet, row2);
            }

            return points;
        }
开发者ID:xoposhiy,项目名称:npoi,代码行数:29,代码来源:HSSFClientAnchor.cs


示例17: GetRowHeightInPoints

 /// <summary>
 /// Gets the row height in points.
 /// </summary>
 /// <param name="sheet">The sheet.</param>
 /// <param name="rowNum">The row num.</param>
 /// <returns></returns>
 private float GetRowHeightInPoints(NPOI.SS.UserModel.ISheet sheet, int rowNum)
 {
     NPOI.SS.UserModel.IRow row = sheet.GetRow(rowNum);
     if (row == null)
         return sheet.DefaultRowHeightInPoints;
     else
         return row.HeightInPoints;
 }
开发者ID:hijson,项目名称:npoi,代码行数:14,代码来源:HSSFClientAnchor.cs


示例18: Serialize

 public override void Serialize(NPOI.Util.ILittleEndianOutput out1)
 {
     base.Serialize(out1);
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:4,代码来源:DropBarRecord.cs


示例19: VisitRecord

 public void VisitRecord(NPOI.HSSF.Record.Record r)
 {
     container.Add((RecordBase)r);
 }
开发者ID:WPG,项目名称:npoi,代码行数:4,代码来源:InternalChart.cs


示例20: ActivateSheet

        private void ActivateSheet(NPOI.SS.UserModel.Sheet sheet) {
            DataTable dt = new DataTable(sheet.SheetName);
            int maxCx = 0;
            int cy = sheet.PhysicalNumberOfRows;
            for (int y = 0; y < cy; y++) {
                NPOI.SS.UserModel.Row row = sheet.GetRow(y);
                if (row != null) {
                    int cx = row.PhysicalNumberOfCells;
                    maxCx = Math.Max(maxCx, row.FirstCellNum + cx);
                }
            }
            int maxCy = sheet.FirstRowNum + cy;

            for (int x = 0; x < maxCx; x++) {
                DataColumn col = dt.Columns.Add("C" + (1 + x), typeof(String));
            }
            for (int vy = 0; vy < maxCy; vy++) {
                DataRow dr = dt.NewRow();
                if (vy >= sheet.FirstRowNum) {
                    int y = vy - sheet.FirstRowNum;
                    NPOI.SS.UserModel.Row row = sheet.GetRow(y);
                    for (int vx = 0; vx < maxCx; vx++) {
                        dr[vx] = "";
                        if (row != null) {
                            if (vx >= row.FirstCellNum) {
                                int x = vx - row.FirstCellNum;
                                NPOI.SS.UserModel.Cell cell = row.GetCell(x);
                                dr[vx] = (cell != null) ? cell.ToString() : "";
                            }
                        }
                    }
                }
                dt.Rows.Add(dr);
            }

            gv.DataSource = dt;

            foreach (DataGridViewColumn col in gv.Columns) {
                col.ReadOnly = true;
            }

            gv.AutoResizeColumns();
            gv.AutoResizeRows();
        }
开发者ID:windrobin,项目名称:kumpro,代码行数:44,代码来源:VwXls.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NReader类代码示例发布时间:2022-05-24
下一篇:
C# NPC类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap