Example #1
3
	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);
		}
	}
 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);
 }
Example #3
1
 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);
 }
Example #4
1
        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;
        }
Example #5
1
 //[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);
     }
 }
Example #6
1
        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;
        }
Example #7
0
 public void Serialize(NPOI.Util.IO.LittleEndianOutput out1)
 {
     out1.WriteShort(FirstRow);
     out1.WriteShort(LastRow);
     out1.WriteByte(FirstColumn);
     out1.WriteByte(LastColumn);
 }
Example #8
0
 public ArrayRecord(NPOI.SS.Formula.Formula formula, CellRangeAddress8Bit range)
     : base(range)
 {
     _options = 0; //YK: Excel 2007 leaves this field unset
     _field3notUsed = 0;
     _formula = formula;
 }
 public static HSSFEvaluationWorkbook Create(NPOI.SS.UserModel.IWorkbook book)
 {
     if (book == null)
     {
         return null;
     }
     return new HSSFEvaluationWorkbook((HSSFWorkbook)book);
 }
Example #10
0
 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);
 }
Example #11
0
 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);
 }
Example #12
0
  /**
   * 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);
  }
 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;
 }
Example #14
0
 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;
 }
Example #15
0
        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++);
        }
Example #16
0
        /// <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;
        }
Example #17
0
 /// <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;
 }
Example #18
0
 public override void Serialize(NPOI.Util.ILittleEndianOutput out1)
 {
     base.Serialize(out1);
 }
Example #19
0
 public void VisitRecord(NPOI.HSSF.Record.Record r)
 {
     container.Add((RecordBase)r);
 }
Example #20
0
        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();
        }
Example #21
0
 public override void Serialize(NPOI.Util.ILittleEndianOutput out1)
 {
     base.Serialize(out1);
     //fillOption.Serialize(out1);
     //tertiaryFillOption.Serialize(out1);
 }
Example #22
0
        /// <summary>
        /// adds a merged region of cells (hence those cells form one)
        /// </summary>
        /// <param name="region">region (rowfrom/colfrom-rowto/colto) to merge</param>
        /// <returns>index of this region</returns>
        public int AddMergedRegion(NPOI.SS.Util.CellRangeAddress region)
        {
            region.Validate(SpreadsheetVersion.EXCEL97);
            // throw IllegalStateException if the argument CellRangeAddress intersects with
            // a multi-cell array formula defined in this sheet
            ValidateArrayFormulas(region);

            return _sheet.AddMergedRegion(region.FirstRow,
                    region.FirstColumn,
                    region.LastRow,
                    region.LastColumn);
        }
Example #23
0
 public int AddMergedRegion(NPOI.SS.Util.Region region)
 {
     return _sheet.AddMergedRegion(region.RowFrom,
             region.ColumnFrom,
             region.RowTo,
             region.ColumnTo);
 }
Example #24
0
 /// <summary>
 /// Sets the default column style for a given column.  POI will only apply this style to new cells Added to the _sheet.
 /// </summary>
 /// <param name="column">the column index</param>
 /// <param name="style">the style to set</param>
 public void SetDefaultColumnStyle(int column, NPOI.SS.UserModel.ICellStyle style)
 {
     _sheet.SetDefaultColumnStyle(column, style.Index);
 }
Example #25
0
 /// <summary>
 /// Sets the size of the margin in inches.
 /// </summary>
 /// <param name="margin">which margin to get.</param>
 /// <param name="size">the size of the margin</param>
 public void SetMargin(NPOI.SS.UserModel.MarginType margin, double size)
 {
     switch (margin)
     {
         case MarginType.FooterMargin:
             _sheet.PageSettings.PrintSetup.FooterMargin = (size);
             break;
         case MarginType.HeaderMargin:
             _sheet.PageSettings.PrintSetup.HeaderMargin = (size);
             break;
         default:
             _sheet.PageSettings.SetMargin(margin, size);
             break;
     }
 }
Example #26
0
 /// <summary>
 /// Gets the size of the margin in inches.
 /// </summary>
 /// <param name="margin">which margin to get.</param>
 /// <returns>the size of the margin</returns>
 public double GetMargin(NPOI.SS.UserModel.MarginType margin)
 {
     switch (margin)
     {
         case MarginType.FooterMargin:
             return _sheet.PageSettings.PrintSetup.FooterMargin;
         case MarginType.HeaderMargin:
             return _sheet.PageSettings.PrintSetup.HeaderMargin;
         default:
             return _sheet.PageSettings.GetMargin(margin);
     }
 }
Example #27
0
 /// <summary>
 /// Creates a split pane. Any existing freezepane or split pane is overwritten.
 /// </summary>
 /// <param name="xSplitPos">Horizonatal position of split (in 1/20th of a point).</param>
 /// <param name="ySplitPos">Vertical position of split (in 1/20th of a point).</param>
 /// <param name="leftmostColumn">Left column visible in right pane.</param>
 /// <param name="topRow">Top row visible in bottom pane.</param>
 /// <param name="activePane">Active pane.  One of: PANE_LOWER_RIGHT,PANE_UPPER_RIGHT, PANE_LOWER_LEFT, PANE_UPPER_LEFT</param>
 public void CreateSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, NPOI.SS.UserModel.PanePosition activePane)
 //this would have the same parameter sequence as the internal method and matches the content of the description above,
 // if this signature changed do it in ISheet, too.
 // public void CreateSplitPane(int xSplitPos, int ySplitPos, int topRow, int leftmostColumn, NPOI.SS.UserModel.PanePosition activePane)
 {
     Sheet.CreateSplitPane(xSplitPos, ySplitPos, topRow, leftmostColumn, activePane);
 }
Example #28
0
 private static bool ContainsCell(NPOI.SS.Util.CellRangeAddress cr, int rowIx, int colIx)
 {
     if (cr.FirstRow <= rowIx && cr.LastRow >= rowIx
             && cr.FirstColumn <= colIx && cr.LastColumn >= colIx)
     {
         return true;
     }
     return false;
 }
Example #29
0
 /// <summary>
 /// Sets the bottom border of region.
 /// </summary>
 /// <param name="region">The region.</param>
 /// <param name="borderType">Type of the border.</param>
 /// <param name="color">The color.</param>
 public void SetBorderBottomOfRegion(CellRangeAddress region, NPOI.SS.UserModel.BorderStyle borderType, short color)
 {
     HSSFRegionUtil.SetBottomBorderColor(color, region, this, _workbook);
     HSSFRegionUtil.SetBorderBottom(borderType, region, this, _workbook);
 }
Example #30
-18
        //[Obsolete]
        //public static void SetBorderLeft(NPOI.SS.UserModel.CellBorderType border, Region region, HSSFSheet sheet,
        //        HSSFWorkbook workbook)
        //{
        //    SetBorderLeft(border, toCRA(region), sheet, workbook);
        //}
        /// <summary>
        /// Sets the left border for a region of cells by manipulating the cell style
        /// of the individual cells on the left
        /// </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 SetBorderLeft(NPOI.SS.UserModel.CellBorderType border, CellRangeAddress region, HSSFSheet sheet,
                HSSFWorkbook workbook)
        {
            int rowStart = region.FirstRow;
            int rowEnd = region.LastRow;
            int column = region.FirstColumn;

            CellPropertySetter cps = new CellPropertySetter(workbook, HSSFCellUtil.BORDER_LEFT, (int)border);
            for (int i = rowStart; i <= rowEnd; i++)
            {
                cps.SetProperty(HSSFCellUtil.GetRow(i, sheet), column);
            }
        }