用于生成 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.

71 lines
2.3 KiB

8 years ago
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for Additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
namespace NPOI.SS
8 years ago
{
8 years ago
using System;
using NUnit.Framework;
using NPOI.HSSF.UserModel;
using NPOI.OpenXml4Net.OPC;
using NPOI.POIFS.FileSystem;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
8 years ago
using TestCases.HSSF;
using System.Configuration;
using System.IO;
8 years ago
[TestFixture]
public class TestWorkbookFactory
{
private String xls;
private String xlsx;
private String txt;
8 years ago
string testdataPath;
8 years ago
[SetUp]
public void SetUp()
{
xls = "SampleSS.xls";
xlsx = "SampleSS.xlsx";
txt = "SampleSS.txt";
testdataPath = ConfigurationManager.AppSettings["POI.testdata.path"] + "\\spreadsheet\\";
8 years ago
}
[Test]
public void TestCreateNative()
{
IWorkbook wb;
// POIFS -> hssf
wb = WorkbookFactory.Create(
new POIFSFileSystem(HSSFTestDataSamples.OpenSampleFileStream(xls))
);
Assert.IsNotNull(wb);
Assert.IsTrue(wb is HSSFWorkbook);
wb.Close();
// Package -> xssf
wb = WorkbookFactory.Create(
OPCPackage.Open(
HSSFTestDataSamples.OpenSampleFileStream(xlsx))
);
Assert.IsNotNull(wb);
Assert.IsTrue(wb is XSSFWorkbook);
}
}
8 years ago
}