用于生成 Office 文件的 .NET 组件。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.6 KiB

using System;
using System.Collections.Generic;
using System.Text;
using TestCases.SS;
using NPOI.HSSF.UserModel;
using NPOI.SS;
using NPOI.SS.UserModel;
namespace TestCases.HSSF
{
public class HSSFITestDataProvider : ITestDataProvider
{
public IWorkbook OpenSampleWorkbook(String sampleFileName)
{
return HSSFTestDataSamples.OpenSampleWorkbook(sampleFileName);
}
public IWorkbook WriteOutAndReadBack(IWorkbook original)
{
if (!(original is HSSFWorkbook))
{
throw new ArgumentException("Expected an instance of HSSFWorkbook");
}
return HSSFTestDataSamples.WriteOutAndReadBack((HSSFWorkbook)original);
}
public IWorkbook CreateWorkbook()
{
return new HSSFWorkbook();
}
public IFormulaEvaluator CreateFormulaEvaluator(IWorkbook wb)
{
return new HSSFFormulaEvaluator((HSSFWorkbook)wb);
}
public byte[] GetTestDataFileContent(String fileName)
{
return POIDataSamples.GetSpreadSheetInstance().ReadFile(fileName);
}
public SpreadsheetVersion GetSpreadsheetVersion()
{
return SpreadsheetVersion.EXCEL97;
}
public string StandardFileNameExtension
{
get { return "xls"; }
}
private HSSFITestDataProvider() { }
private static HSSFITestDataProvider inst = new HSSFITestDataProvider();
public static HSSFITestDataProvider Instance
{
get
{
return inst;
}
}
}
}