本文整理汇总了C#中NPOI.SS.Util.CellRangeAddress类的典型用法代码示例。如果您正苦于以下问题:C# CellRangeAddress类的具体用法?C# CellRangeAddress怎么用?C# CellRangeAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CellRangeAddress类属于NPOI.SS.Util命名空间,在下文中一共展示了CellRangeAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyPercentageFormatting
protected void ApplyPercentageFormatting(int column, int rowFromInclusive, int rowtoInclusive)
{
string colString = CellReference.ConvertNumToColString(column);
string range = String.Format("{0}{1}:{0}{2}", colString, rowFromInclusive, rowtoInclusive);
var region = new CellRangeAddress[] { CellRangeAddress.ValueOf(range) };
sheet.SheetConditionalFormatting.AddConditionalFormatting(region, PercentageFormattingRules);
}
示例2: FeatRecord
public FeatRecord(RecordInputStream in1)
{
futureHeader = new FtrHeader(in1);
isf_sharedFeatureType = in1.ReadShort();
reserved1 = (byte)in1.ReadByte();
reserved2 = in1.ReadInt();
int cref = in1.ReadUShort();
cbFeatData = in1.ReadInt();
reserved3 = in1.ReadShort();
cellRefs = new CellRangeAddress[cref];
for (int i = 0; i < cellRefs.Length; i++)
{
cellRefs[i] = new CellRangeAddress(in1);
}
switch (isf_sharedFeatureType)
{
case FeatHdrRecord.SHAREDFEATURES_ISFPROTECTION:
sharedFeature = new FeatProtection(in1);
break;
case FeatHdrRecord.SHAREDFEATURES_ISFFEC2:
sharedFeature = new FeatFormulaErr2(in1);
break;
case FeatHdrRecord.SHAREDFEATURES_ISFFACTOID:
sharedFeature = new FeatSmartTag(in1);
break;
default:
System.Console.WriteLine("Unknown Shared Feature " + isf_sharedFeatureType + " found!");
break;
}
}
示例3: Intersect
/**
* Intersect this range with the specified range.
*
* @param crB - the specified range
* @return code which reflects how the specified range is related to this range.<br/>
* Possible return codes are:
* NO_INTERSECTION - the specified range is outside of this range;<br/>
* OVERLAP - both ranges partially overlap;<br/>
* INSIDE - the specified range is inside of this one<br/>
* ENCLOSES - the specified range encloses (possibly exactly the same as) this range<br/>
*/
public static int Intersect(CellRangeAddress crA, CellRangeAddress crB)
{
int firstRow = crB.FirstRow;
int lastRow = crB.LastRow;
int firstCol = crB.FirstColumn;
int lastCol = crB.LastColumn;
if
(
gt(crA.FirstRow, lastRow) ||
lt(crA.LastRow, firstRow) ||
gt(crA.FirstColumn, lastCol) ||
lt(crA.LastColumn, firstCol)
)
{
return NO_INTERSECTION;
}
else if (Contains(crA, crB))
{
return INSIDE;
}
else if (Contains(crB, crA))
{
return ENCLOSES;
}
else
{
return OVERLAP;
}
}
示例4: CreateAdresse
private void CreateAdresse()
{
var merge = new CellRangeAddress(6, 7, BeginCadreInformation, BeginCadreInformation + LongeurCadre);
_cadreCreator.Create(6, BeginCadreInformation, 7, BeginCadreInformation + LongeurCadre, new byte[3] { 255, 255, 255 }, BorderStyle.Medium, merge, true, true);
_sheet.GetRow(6).GetCell(BeginCadreInformation).SetCellValue(" - 69400 VILLEFRANCHE-SUR-SAONE");
}
示例5: Main
static void Main(string[] args)
{
InitializeWorkbook();
ISheet sheet = hssfworkbook.CreateSheet("new sheet");
IRow row = sheet.CreateRow(0);
row.HeightInPoints = 30;
ICell cell = row.CreateCell(0);
//set the title of the sheet
cell.SetCellValue("Sales Report");
ICellStyle style = hssfworkbook.CreateCellStyle();
style.Alignment = HorizontalAlignment.CENTER;
//create a font style
IFont font = hssfworkbook.CreateFont();
font.FontHeight = 20*20;
style.SetFont(font);
cell.CellStyle = style;
//merged cells on single row
//ATTENTION: don't use Region class, which is obsolete
sheet.AddMergedRegion(new CellRangeAddress(0, 0, 0, 5));
//merged cells on mutiple rows
CellRangeAddress region = new CellRangeAddress(2, 4, 2, 4);
sheet.AddMergedRegion(region);
//set enclosed border for the merged region
((HSSFSheet)sheet).SetEnclosedBorderOfRegion(region, BorderStyle.DOTTED, NPOI.HSSF.Util.HSSFColor.RED.index);
WriteToFile();
}
示例6: CreateAdresseArmoire
private void CreateAdresseArmoire()
{
var merge = new CellRangeAddress(6, 7, 1, 5);
_cadreCreator.Create(6, 1, 7, 5, new byte[3] { 255, 255, 255 }, BorderStyle.Medium, merge, true, true);
_sheet.GetRow(6).GetCell(1).SetCellValue(" - 69400 VILLEFRANCHE-SUR-SAONE");
}
示例7: CreateRow
private void CreateRow(IEnumerable<Cell> row, Row currentRow)
{
int columnOrdinal = 0;
foreach (var cell in row)
{
if (cell.ColumnSpan > 1)
{
int rangeStartColumn = columnOrdinal;
for (int i = 0; i < cell.ColumnSpan; i++)
{
NPOI.SS.UserModel.Cell current = CreateCell(cell, currentRow, columnOrdinal);
if (i == 0) current.SetCellValue(cell.Value);
columnOrdinal++;
}
var cra = new CellRangeAddress(currentRow.RowNum, currentRow.RowNum, rangeStartColumn,
rangeStartColumn + (cell.ColumnSpan - 1));
_sheet.AddMergedRegion(cra);
}
else
{
CreateCell(cell, currentRow, columnOrdinal).SetCellValue(cell.Value);
columnOrdinal++;
}
}
}
示例8: CFHeaderRecord
public CFHeaderRecord(CellRangeAddress[] regions, int nRules)
{
CellRangeAddress[] unmergedRanges = regions;
CellRangeAddress[] mergeCellRanges = CellRangeUtil.MergeCellRanges(unmergedRanges);
CellRanges= mergeCellRanges;
field_1_numcf = nRules;
}
示例9: Test_47701
public void Test_47701()
{
byte[] data = HexRead.ReadFromString(
"15, 00, 12, 00, 12, 00, 02, 00, 11, 20, " +
"00, 00, 00, 00, 80, 3D, 03, 05, 00, 00, " +
"00, 00, 0C, 00, 14, 00, 00, 00, 00, 00, " +
"00, 00, 00, 00, 00, 00, 01, 00, 0A, 00, " +
"00, 00, 10, 00, 01, 00, 13, 00, EE, 1F, " +
"10, 00, 09, 00, 40, 9F, 74, 01, 25, 09, " +
"00, 0C, 00, 07, 00, 07, 00, 07, 04, 00, " +
"00, 00, 08, 00, 00, 00");
RecordInputStream in1 = TestcaseRecordInputStream.Create(ObjRecord.sid, data);
// check read OK
ObjRecord record = new ObjRecord(in1);
Assert.AreEqual(3, record.SubRecords.Count);
SubRecord sr = record.SubRecords[(2)];
Assert.IsTrue(sr is LbsDataSubRecord);
LbsDataSubRecord lbs = (LbsDataSubRecord)sr;
Assert.AreEqual(4, lbs.NumberOfItems);
Assert.IsTrue(lbs.Formula is AreaPtg);
AreaPtg ptg = (AreaPtg)lbs.Formula;
CellRangeAddress range = new CellRangeAddress(
ptg.FirstRow, ptg.LastRow, ptg.FirstColumn, ptg.LastColumn);
Assert.AreEqual("H10:H13", range.FormatAsString());
// check that it re-Serializes to the same data
byte[] ser = record.Serialize();
TestcaseRecordInputStream.ConfirmRecordEncoding(ObjRecord.sid, data, ser);
}
示例10: Contains
/**
* Check if the specified range is located inside of this cell range.
*
* @param crB
* @return true if this cell range Contains the argument range inside if it's area
*/
public static bool Contains(CellRangeAddress crA, CellRangeAddress crB)
{
int firstRow = crB.FirstRow;
int lastRow = crB.LastRow;
int firstCol = crB.FirstColumn;
int lastCol = crB.LastColumn;
return le(crA.FirstRow, firstRow) && ge(crA.LastRow, lastRow)
&& le(crA.FirstColumn, firstCol) && ge(crA.LastColumn, lastCol);
}
示例11: CreateAdresseChambrePB
private void CreateAdresseChambrePB(ref int hauteur)
{
var bleu = new byte[3] { 153, 204, 255 };
var endHauteur = hauteur + 1;
var merge = new CellRangeAddress(hauteur, endHauteur, 20, 23);
_cadreCreator.Create(hauteur, 20, endHauteur, 23, bleu, BorderStyle.Medium, merge, true);
_sheet.GetRow(hauteur).GetCell(20).SetCellValue(" - 69400 VILLEFRANCHE-SUR-SAONE");
hauteur = hauteur + 2;
}
示例12: TestLoad
public void TestLoad()
{
CellRangeAddress cref = new CellRangeAddress(
TestcaseRecordInputStream.Create(0x000, data)
);
Assert.AreEqual(2, cref.FirstRow);
Assert.AreEqual(4, cref.LastRow);
Assert.AreEqual(0, cref.FirstColumn);
Assert.AreEqual(3, cref.LastColumn);
Assert.AreEqual(8, CellRangeAddress.ENCODED_SIZE);
}
示例13: MergeCellsRecord
/**
* Constructs a MergedCellsRecord and Sets its fields appropriately
* @param in the RecordInputstream to Read the record from
*/
public MergeCellsRecord(RecordInputStream in1)
{
int nRegions = in1.ReadUShort();
CellRangeAddress[] cras = new CellRangeAddress[nRegions];
for (int i = 0; i < nRegions; i++)
{
cras[i] = new CellRangeAddress(in1);
}
_numberOfRegions = nRegions;
_startIndex = 0;
_regions = cras;
}
示例14: SetBorderLeft
//[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);
}
}
示例15: SetBorderLeft
/**
* Sets the left border for a region of cells by manipulating the cell style of the individual
* cells on the left
*
* @param border The new border
* @param region The region that should have the border
* @param workbook The workbook that the region is on.
* @param sheet The sheet that the region is on.
*/
public static void SetBorderLeft(int border, CellRangeAddress region, ISheet sheet,
IWorkbook workbook)
{
int rowStart = region.FirstRow;
int rowEnd = region.LastRow;
int column = region.FirstColumn;
CellPropertySetter cps = new CellPropertySetter(workbook, CellUtil.BORDER_LEFT, border);
for (int i = rowStart; i <= rowEnd; i++)
{
cps.SetProperty(CellUtil.GetRow(i, sheet), column);
}
}