本文整理汇总了C#中NPOI类的典型用法代码示例。如果您正苦于以下问题:C# NPOI类的具体用法?C# NPOI怎么用?C# NPOI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NPOI类属于命名空间,在下文中一共展示了NPOI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例6: Serialize
public void Serialize(NPOI.Util.IO.LittleEndianOutput out1)
{
out1.WriteShort(FirstRow);
out1.WriteShort(LastRow);
out1.WriteByte(FirstColumn);
out1.WriteByte(LastColumn);
}
示例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;
}
示例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);
}
}
示例9: Create
public static HSSFEvaluationWorkbook Create(NPOI.SS.UserModel.IWorkbook book)
{
if (book == null)
{
return null;
}
return new HSSFEvaluationWorkbook((HSSFWorkbook)book);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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++);
}