本文整理汇总了C#中Sheet类的典型用法代码示例。如果您正苦于以下问题:C# Sheet类的具体用法?C# Sheet怎么用?C# Sheet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sheet类属于命名空间,在下文中一共展示了Sheet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert
///<summary>Inserts one Sheet into the database. Provides option to use the existing priKey.</summary>
internal static long Insert(Sheet sheet,bool useExistingPK)
{
if(!useExistingPK && PrefC.RandomKeys) {
sheet.SheetNum=ReplicationServers.GetKey("sheet","SheetNum");
}
string command="INSERT INTO sheet (";
if(useExistingPK || PrefC.RandomKeys) {
command+="SheetNum,";
}
command+="SheetType,PatNum,DateTimeSheet,FontSize,FontName,Width,Height,IsLandscape,InternalNote,Description,ShowInTerminal,IsWebForm) VALUES(";
if(useExistingPK || PrefC.RandomKeys) {
command+=POut.Long(sheet.SheetNum)+",";
}
command+=
POut.Int ((int)sheet.SheetType)+","
+ POut.Long (sheet.PatNum)+","
+ POut.DateT (sheet.DateTimeSheet)+","
+ POut.Float (sheet.FontSize)+","
+"'"+POut.String(sheet.FontName)+"',"
+ POut.Int (sheet.Width)+","
+ POut.Int (sheet.Height)+","
+ POut.Bool (sheet.IsLandscape)+","
+"'"+POut.String(sheet.InternalNote)+"',"
+"'"+POut.String(sheet.Description)+"',"
+ POut.Byte (sheet.ShowInTerminal)+","
+ POut.Bool (sheet.IsWebForm)+")";
if(useExistingPK || PrefC.RandomKeys) {
Db.NonQ(command);
}
else {
sheet.SheetNum=Db.NonQ(command,true);
}
return sheet.SheetNum;
}
示例2: UpdateSupport
public void UpdateSupport(Sheet supported) {
// Update the support sets of cells referred from an array formula only once
if (!supportAdded) {
formula.AddToSupportSets(supported, formulaCol, formulaRow, 1, 1);
supportAdded = true;
}
}
示例3: InsertRowCols
public override void InsertRowCols(Dictionary<Expr, Adjusted<Expr>> adjusted,
Sheet modSheet,
bool thisSheet,
int R,
int N,
int r,
bool doRows) {}
示例4: InsertRowCols
public abstract void InsertRowCols(Dictionary<Expr, Adjusted<Expr>> adjusted,
Sheet modSheet,
bool thisSheet,
int R,
int N,
int r,
bool doRows);
示例5: SetCellValue
public static bool SetCellValue(this SpreadsheetDocument document, Sheet metadataSheet, string addressName, string value)
{
// If the string exists in the shared string table, get its index.
// If the string doesn't exist in the shared string table, add it and get the next index.
// Assume failure.
bool returnValue = false;
// Open the document for editing.
WorkbookPart wbPart = document.WorkbookPart;
if (metadataSheet != null)
{
Worksheet ws = ((WorksheetPart)(wbPart.GetPartById(metadataSheet.Id))).Worksheet;
Cell theCell = ws.InsertCellInWorksheet(addressName);
// Either retrieve the index of an existing string,
// or insert the string into the shared string table
// and get the index of the new item.
int stringIndex = wbPart.InsertSharedStringItem(value);
theCell.CellValue = new CellValue(stringIndex.ToString());
theCell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
// Save the worksheet.
ws.Save();
returnValue = true;
}
return returnValue;
}
示例6: RemoveCell
public override bool RemoveCell(SupportSet set, Sheet sheet, int col, int row) {
if (Contains(sheet, col, row)) {
// To exclude cell at sheet[col, row], split into up to 4 support ranges
if (rowInt.min < row) // North, column above [col,row]
{
set.Add(Make(sheet, new Interval(col, col), new Interval(rowInt.min, row - 1)));
}
if (row < rowInt.max) // South, column below [col,row]
{
set.Add(Make(sheet, new Interval(col, col), new Interval(row + 1, rowInt.max)));
}
if (colInt.min < col) // West, block to the left of [col,row]
{
set.Add(Make(sheet, new Interval(colInt.min, col - 1), rowInt));
}
if (col < colInt.max) // East, block to the right of [col,row]
{
set.Add(Make(sheet, new Interval(col + 1, colInt.max), rowInt));
}
return true;
}
else {
return false;
}
}
示例7: RemoveFromSupportSets
public void RemoveFromSupportSets(Sheet sheet, int col, int row) {
// Update the support sets of cells referred from an array formula only once
if (!supportRemoved) {
formula.RemoveFromSupportSets(sheet, col, row);
supportRemoved = true;
}
}
示例8: TextCellsAreStored
public void TextCellsAreStored()
{
var sheet = new Sheet();
const string theCell = "A21";
sheet.Put(theCell, "A string");
Assert.That(sheet.Get(theCell), Is.EqualTo("A string"));
}
示例9: columnInserted
/**
* Called when a column is inserted on the specified sheet. Notifies all
* RCIR cells of this change. The default implementation here does nothing
*
* @param s the sheet on which the column was inserted
* @param sheetIndex the sheet index on which the column was inserted
* @param col the column number which was inserted
*/
public override void columnInserted(Sheet s, int sheetIndex, int col)
{
try
{
if (parser == null)
{
byte[] formulaData = formula.getFormulaData();
byte[] formulaBytes = new byte[formulaData.Length - 16];
System.Array.Copy(formulaData, 16,
formulaBytes, 0, formulaBytes.Length);
parser = new FormulaParser(formulaBytes,
this,
getSheet().getWorkbook(),
getSheet().getWorkbook(),
getSheet().getWorkbookSettings());
parser.parse();
}
parser.columnInserted(sheetIndex, col, s == getSheet());
}
catch (FormulaException e)
{
//logger.warn("cannot insert column within formula: " + e.Message);
}
}
示例10: CreateSpreadsheetWorkbook
public static void CreateSpreadsheetWorkbook(string filepath)
{
// Create a spreadsheet document by supplying the filepath.
// By default, AutoSave = true, Editable = true, and Type = xlsx.
SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.
Create(filepath, SpreadsheetDocumentType.Workbook);
// Add a WorkbookPart to the document.
WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart();
workbookpart.Workbook = new Workbook();
// Add a WorksheetPart to the WorkbookPart.
WorksheetPart worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet(new SheetData());
// Add Sheets to the Workbook.
Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.
AppendChild<Sheets>(new Sheets());
// Append a new worksheet and associate it with the workbook.
Sheet sheet = new Sheet()
{
Id = spreadsheetDocument.WorkbookPart.
GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "mySheet"
};
sheets.Append(sheet);
workbookpart.Workbook.Save();
// Close the document.
spreadsheetDocument.Close();
}
示例11: AddNewWorksheet
public void AddNewWorksheet()
{
WorkbookPart workbookPart = spreadSheet.WorkbookPart;
WorksheetPart newWorksheetPart = workbookPart.AddNewPart<WorksheetPart>();
newWorksheetPart.Worksheet = new Worksheet(new SheetData());
newWorksheetPart.Worksheet.Save();
CurrentWorksheetPart = newWorksheetPart;
//workbookPart.SharedStringTablePart.SharedStringTable.Count = workbookPart.SharedStringTablePart.SharedStringTable.Count + 1;
//workbookPart.SharedStringTablePart.SharedStringTable.UniqueCount = workbookPart.SharedStringTablePart.SharedStringTable.UniqueCount + 1;
string relationshipId = workbookPart.GetIdOfPart(newWorksheetPart);
Sheets sheets = workbookPart.Workbook.GetFirstChild<Sheets>();
uint sheetId = 1;
if (sheets.Elements<Sheet>().Count() > 0)
{
sheetId = sheets.Elements<Sheet>().Select(s => s.SheetId.Value).Max() + 1;
}
string sheetName = "Sheet" + sheetId;
// Append the new worksheet and associate it with the workbook.
Sheet sheet = new Sheet() { Id = relationshipId, SheetId = sheetId, Name = sheetName };
sheets.Append(sheet);
workbookPart.Workbook.Save();
}
示例12: InsertWorksheet
private static void InsertWorksheet(string docName)
{
// Open the document for editing.
using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Open(docName, true))
{
// Add a blank WorksheetPart.
WorksheetPart newWorksheetPart = spreadSheet.WorkbookPart.AddNewPart<WorksheetPart>();
newWorksheetPart.Worksheet = new Worksheet(new SheetData());
Sheets sheets = spreadSheet.WorkbookPart.Workbook.GetFirstChild<Sheets>();
string relationshipId = spreadSheet.WorkbookPart.GetIdOfPart(newWorksheetPart);
// Get a unique ID for the new worksheet.
uint sheetId = 1;
if (sheets.Elements<Sheet>().Count() > 0)
{
sheetId = sheets.Elements<Sheet>().Select(s => s.SheetId.Value).Max() + 1;
}
// Give the new worksheet a name.
string sheetName = "Sheet" + sheetId;
// Append the new worksheet and associate it with the workbook.
Sheet sheet = new Sheet() { Id = relationshipId, SheetId = sheetId, Name = sheetName };
sheets.Append(sheet);
}
}
示例13: OpenAndAddToSpreadsheetStream
public static void OpenAndAddToSpreadsheetStream(Stream stream)
{
// Open a SpreadsheetDocument based on a stream.
SpreadsheetDocument spreadsheetDocument =
SpreadsheetDocument.Open(stream, true);
// Add a new worksheet.
WorksheetPart newWorksheetPart = spreadsheetDocument.WorkbookPart.AddNewPart<WorksheetPart>();
newWorksheetPart.Worksheet = new Worksheet(new SheetData());
newWorksheetPart.Worksheet.Save();
Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>();
string relationshipId = spreadsheetDocument.WorkbookPart.GetIdOfPart(newWorksheetPart);
// Get a unique ID for the new worksheet.
uint sheetId = 1;
if (sheets.Elements<Sheet>().Count() > 0)
{
sheetId = sheets.Elements<Sheet>().Select(s => s.SheetId.Value).Max() + 1;
}
// Give the new worksheet a name.
string sheetName = "Sheet" + sheetId;
// Append the new worksheet and associate it with the workbook.
Sheet sheet = new Sheet() { Id = relationshipId, SheetId = sheetId, Name = sheetName };
sheets.Append(sheet);
spreadsheetDocument.WorkbookPart.Workbook.Save();
// Close the document handle.
spreadsheetDocument.Close();
// Caller must close the stream.
}
示例14: MergedCellsRecord
/**
* Constructs this object from the raw data
*
* @param t the raw data
* @param s the sheet
*/
public MergedCellsRecord(Record t, Sheet s)
: base(t)
{
byte[] data = getRecord().getData();
int numRanges = IntegerHelper.getInt(data[0],data[1]);
ranges = new Range[numRanges];
int pos = 2;
int firstRow = 0;
int lastRow = 0;
int firstCol = 0;
int lastCol = 0;
for (int i = 0; i < numRanges; i++)
{
firstRow = IntegerHelper.getInt(data[pos],data[pos + 1]);
lastRow = IntegerHelper.getInt(data[pos + 2],data[pos + 3]);
firstCol = IntegerHelper.getInt(data[pos + 4],data[pos + 5]);
lastCol = IntegerHelper.getInt(data[pos + 6],data[pos + 7]);
ranges[i] = new SheetRangeImpl(s,firstCol,firstRow,
lastCol,lastRow);
pos += 8;
}
}
示例15: InsertRowCols
public override void InsertRowCols(Dictionary<Expr, Adjusted<Expr>> adjusted,
Sheet modSheet,
bool thisSheet,
int R,
int N,
int r,
bool doRows) {
Adjusted<Expr> ae;
if (adjusted.ContainsKey(e) && r < adjusted[e].upper) {
// There is a valid cached adjusted expression
ae = adjusted[e];
}
else {
// Compute a new adjusted expression and insert into the cache
ae = e.InsertRowCols(modSheet, thisSheet, R, N, r, doRows);
Console.WriteLine("Making new adjusted at rowcol " + r
+ "; upper = " + ae.upper);
if (ae.same) { // For better sharing, reuse unadjusted e if same
ae = new Adjusted<Expr>(e, ae.upper, ae.same);
Console.WriteLine("Reusing expression");
}
adjusted[e] = ae;
}
Debug.Assert(r < ae.upper, "Formula.InsertRowCols");
e = ae.e;
}