本文整理汇总了C#中File.peek方法的典型用法代码示例。如果您正苦于以下问题:C# File.peek方法的具体用法?C# File.peek怎么用?C# File.peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File.peek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SharedStringFormulaRecord
/**
* Constructs this string formula
*
* @param t the record
* @param excelFile the excel file
* @param fr the formatting record
* @param es the external sheet
* @param nt the workbook
* @param si the sheet
* @param ws the workbook settings
*/
public SharedStringFormulaRecord(Record t,
File excelFile,
FormattingRecords fr,
ExternalSheet es,
WorkbookMethods nt,
SheetImpl si,
WorkbookSettings ws)
: base(t,fr,es,nt,si,excelFile.getPos())
{
int pos = excelFile.getPos();
// Save the position in the excel file
int filepos = excelFile.getPos();
// Look for the string record in one of the records after the
// formula. Put a cap on it to prevent ednas
Record nextRecord = excelFile.next();
int count = 0;
while (nextRecord.getType() != Type.STRING && count < 4)
{
nextRecord = excelFile.next();
count++;
}
Assert.verify(count < 4," @ " + pos);
byte[] stringData = nextRecord.getData();
// Read in any continuation records
nextRecord = excelFile.peek();
while (nextRecord.getType() == Type.CONTINUE)
{
nextRecord = excelFile.next(); // move the pointer within the data
byte[] d = new byte[stringData.Length + nextRecord.getLength() - 1];
System.Array.Copy(stringData,0,d,0,stringData.Length);
System.Array.Copy(nextRecord.getData(),1,d,
stringData.Length,nextRecord.getLength() - 1);
stringData = d;
nextRecord = excelFile.peek();
}
int chars = IntegerHelper.getInt(stringData[0],stringData[1]);
bool unicode = false;
int startpos = 3;
if (stringData.Length == chars + 2)
{
// string might only consist of a one byte length indicator, instead
// of the more normal 2
startpos = 2;
unicode = false;
}
else if (stringData[2] == 0x1)
{
// unicode string, two byte length indicator
startpos = 3;
unicode = true;
}
else
{
// ascii string, two byte length indicator
startpos = 3;
unicode = false;
}
if (!unicode)
{
value = StringHelper.getString(stringData,chars,startpos,ws);
}
else
{
value = StringHelper.getUnicodeString(stringData,chars,startpos);
}
// Restore the position in the excel file, to enable the SHRFMLA
// record to be picked up
excelFile.setPos(filepos);
}
示例2: StringFormulaRecord
/**
* Constructs this object from the raw data. We need to use the excelFile
* to retrieve the string record which follows this formula record
*
* @param t the raw data
* @param excelFile the excel file
* @param fr the formatting records
* @param es the external sheet records
* @param nt the workbook
* @param si the sheet impl
* @param ws the workbook settings
*/
public StringFormulaRecord(Record t,File excelFile,
FormattingRecords fr,
ExternalSheet es,
WorkbookMethods nt,
SheetImpl si,
WorkbookSettings ws)
: base(t,fr,si)
{
externalSheet = es;
nameTable = nt;
data = getRecord().getData();
int pos = excelFile.getPos();
// Look for the string record in one of the records after the
// formula. Put a cap on it to prevent looping
Record nextRecord = excelFile.next();
int count = 0;
while (nextRecord.getType() != Type.STRING && count < 4)
{
nextRecord = excelFile.next();
count++;
}
Assert.verify(count < 4," @ " + pos);
byte[] stringData = nextRecord.getData();
// Read in any continuation records
nextRecord = excelFile.peek();
while (nextRecord.getType() == Type.CONTINUE)
{
nextRecord = excelFile.next(); // move the pointer within the data
byte[] d = new byte[stringData.Length + nextRecord.getLength() - 1];
System.Array.Copy(stringData,0,d,0,stringData.Length);
System.Array.Copy(nextRecord.getData(),1,d,
stringData.Length,nextRecord.getLength() - 1);
stringData = d;
nextRecord = excelFile.peek();
}
readString(stringData,ws);
}