本文整理汇总了C#中IWorkbook.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IWorkbook.GetType方法的具体用法?C# IWorkbook.GetType怎么用?C# IWorkbook.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorkbook
的用法示例。
在下文中一共展示了IWorkbook.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteOutAndReadBack
public static IWorkbook WriteOutAndReadBack(IWorkbook wb)
{
IWorkbook result;
try
{
using (MemoryStream baos = new MemoryStream(8192))
{
wb.Write(baos);
using (Stream is1 = new MemoryStream(baos.ToArray()))
{
if (wb is HSSFWorkbook)
{
result = new HSSFWorkbook(is1);
}
else if (wb is XSSFWorkbook)
{
result = new XSSFWorkbook(is1);
}
else
{
throw new RuntimeException("Unexpected workbook type ("
+ wb.GetType().Name + ")");
}
}
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
return result;
}
示例2: WriteOutAndReadBack
public IWorkbook WriteOutAndReadBack(IWorkbook original)
{
if (!(original is XSSFWorkbook))
{
throw new ArgumentException("Expected an instance of XSSFWorkbook, but had " + original.GetType().Name);
}
return XSSFTestDataSamples.WriteOutAndReadBack((XSSFWorkbook)original);
}
示例3: CreateEvaluationWorkbook
private static IEvaluationWorkbook CreateEvaluationWorkbook(IWorkbook wb)
{
if (wb is HSSFWorkbook)
{
return HSSFEvaluationWorkbook.Create((HSSFWorkbook)wb);
}
// TODO rearrange POI build to allow this
// if (wb is XSSFWorkbook) {
// return XSSFEvaluationWorkbook.Create((XSSFWorkbook) wb);
// }
throw new ArgumentException("Unexpected workbook type (" + wb.GetType().Name + ")");
}
示例4: WriteOutAndReadBack
public static IWorkbook WriteOutAndReadBack(IWorkbook wb)
{
IWorkbook result;
try
{
using (MemoryStream baos = new MemoryStream(8192))
{
Stopwatch sw = new Stopwatch();
sw.Start();
wb.Write(baos);
sw.Stop();
Debug.WriteLine("XSSFWorkbook write time: " + sw.ElapsedMilliseconds + "ms");
using (Stream is1 = new MemoryStream(baos.ToArray()))
{
if (wb is HSSFWorkbook)
{
result = new HSSFWorkbook(is1);
}
else if (wb is XSSFWorkbook)
{
Stopwatch sw2 = new Stopwatch();
sw2.Start();
result = new XSSFWorkbook(is1);
sw2.Stop();
Debug.WriteLine("XSSFWorkbook parse time: " + sw2.ElapsedMilliseconds + "ms");
}
else
{
throw new RuntimeException("Unexpected workbook type ("
+ wb.GetType().Name + ")");
}
}
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
return result;
}
示例5: CreateFormulaEvaluator
/// <summary>
/// Creates a specific FormulaEvaluator for the given workbook.
/// </summary>
public static IFormulaEvaluator CreateFormulaEvaluator(IWorkbook workbook)
{
if (typeof(HSSFWorkbook) == workbook.GetType())
{
return new HSSFFormulaEvaluator(workbook as HSSFWorkbook);
}
else
{
return new XSSFFormulaEvaluator(workbook as XSSFWorkbook);
}
}