本文整理汇总了C#中NPOI.SS.UserModel.DataFormatter类的典型用法代码示例。如果您正苦于以下问题:C# DataFormatter类的具体用法?C# DataFormatter怎么用?C# DataFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataFormatter类属于NPOI.SS.UserModel命名空间,在下文中一共展示了DataFormatter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValue
/// <summary>
/// Gets the value.
/// </summary>
/// <param name="cell">The ICell object.</param>
/// <param name="dataFormatter">The data formatter.</param>
/// <param name="formulaEvaluator">The formula evaluator.</param>
/// <returns>Value string.</returns>
public static string GetValue(ICell cell, DataFormatter dataFormatter, IFormulaEvaluator formulaEvaluator)
{
string ret = string.Empty;
if (null == cell)
{
return ret;
}
ret = dataFormatter.FormatCellValue(cell, formulaEvaluator);
// remove line break
return ret.Replace("\n", " ");
}
示例2: TestColours
public void TestColours()
{
//DataFormatter dfUS = new DataFormatter(Locale.US);
DataFormatter dfUS = new DataFormatter(System.Globalization.CultureInfo.GetCultureInfo("en-US"));
String[] formats = new String[] {
"##.##",
"[WHITE]##.##",
"[BLACK]##.##;[RED]-##.##",
"[COLOR11]##.##;[COLOR 43]-##.00",
};
foreach (String format in formats)
{
Assert.AreEqual(
"12.34",
dfUS.FormatRawCellContents(12.343, -1, format),
"Wrong format for: " + format
);
Assert.AreEqual(
"-12.34",
dfUS.FormatRawCellContents(-12.343, -1, format),
"Wrong format for: " + format
);
}
// Ensure that random square brackets remain
Assert.AreEqual("12.34[a]", dfUS.FormatRawCellContents(12.343, -1, "##.##[a]"));
Assert.AreEqual("[ab]12.34[x]", dfUS.FormatRawCellContents(12.343, -1, "[ab]##.##[x]"));
}
示例3: InitializeMembers
//
// Initialize from a stream of Excel file
//
protected void InitializeMembers(Stream excelFileStream)
{
this.workbook = WorkbookFactory.Create(excelFileStream);
if (this.workbook != null)
{
this.dataFormatter = new DataFormatter(CultureInfo.InvariantCulture);
this.formulaEvaluator = WorkbookFactory.CreateFormulaEvaluator(this.workbook);
}
}
示例4: TestLocale
public void TestLocale()
{
DataFormatter dfUS = new DataFormatter(System.Globalization.CultureInfo.GetCultureInfo("en-US"));
DataFormatter dfFR = new DataFormatter(System.Globalization.CultureInfo.GetCultureInfo("fr-FR"));
Assert.AreEqual("1234", dfUS.FormatRawCellContents(1234, -1, "@"));
Assert.AreEqual("1234", dfFR.FormatRawCellContents(1234, -1, "@"));
Assert.AreEqual("12.34", dfUS.FormatRawCellContents(12.34, -1, "@"));
Assert.AreEqual("12,34", dfFR.FormatRawCellContents(12.34, -1, "@"));
}
示例5: TestAMPM
public void TestAMPM()
{
DataFormatter dfUS = new DataFormatter(System.Globalization.CultureInfo.GetCultureInfo("en-US"));
Assert.AreEqual("06:00", dfUS.FormatRawCellContents(0.25, -1, "hh:mm"));
Assert.AreEqual("18:00", dfUS.FormatRawCellContents(0.75, -1, "hh:mm"));
Assert.AreEqual("06:00 AM", dfUS.FormatRawCellContents(0.25, -1, "hh:mm AM/PM"));
Assert.AreEqual("06:00 PM", dfUS.FormatRawCellContents(0.75, -1, "hh:mm AM/PM"));
Assert.AreEqual("1904-01-01 06:00:00 AM", dfUS.FormatRawCellContents(0.25, -1, "yyyy-mm-dd hh:mm:ss AM/PM", true));
Assert.AreEqual("1904-01-01 06:00:00 PM", dfUS.FormatRawCellContents(0.75, -1, "yyyy-mm-dd hh:mm:ss AM/PM", true));
}
示例6: SetUp
public void SetUp()
{
wb = new HSSFWorkbook();
ISheet sheet = wb.CreateSheet("new sheet");
style = wb.CreateCellStyle();
IDataFormat fmt = wb.CreateDataFormat();
style.DataFormat=(fmt.GetFormat("hh:mm:ss"));
cell11 = sheet.CreateRow(0).CreateCell(0);
form = new DataFormatter();
Evaluator = new HSSFFormulaEvaluator(wb);
}
示例7: TestLocaleBasedFormats
public void TestLocaleBasedFormats()
{
DataFormatter dfUS = new DataFormatter(System.Globalization.CultureInfo.GetCultureInfo("en-US"));
// Standard formats
Assert.AreEqual("63", dfUS.FormatRawCellContents(63.0, -1, "[$-1010409]General"));
Assert.AreEqual("63", dfUS.FormatRawCellContents(63.0, -1, "[$-1010409]@"));
// Regular numeric style formats
Assert.AreEqual("63", dfUS.FormatRawCellContents(63.0, -1, "[$-1010409]##"));
Assert.AreEqual("63", dfUS.FormatRawCellContents(63.0, -1, "[$-1010409]00"));
}
示例8: DISABLEDtestCustomFormats
/**
* TODO Fix these so that they work
*/
public void DISABLEDtestCustomFormats()
{
DataFormatter dfUS = new DataFormatter(System.Globalization.CultureInfo.GetCultureInfo("en-US"), true);
String fmt;
fmt = "\"At\" H:MM AM/PM \"on\" DDDD MMMM D\",\" YYYY";
Assert.AreEqual(
"At 4:20 AM on Thursday May 17, 2007",
dfUS.FormatRawCellContents(39219.1805636921, -1, fmt)
);
fmt = "0 \"dollars and\" .00 \"cents\"";
Assert.AreEqual("19 dollars and .99 cents", dfUS.FormatRawCellContents(19.99, -1, fmt));
}
示例9: doTest49928Core
public void doTest49928Core(IWorkbook wb)
{
DataFormatter df = new DataFormatter();
ISheet sheet = wb.GetSheetAt(0);
ICell cell = sheet.GetRow(0).GetCell(0);
ICellStyle style = cell.CellStyle;
String poundFmt = "\"\u00a3\"#,##0;[Red]\\-\"\u00a3\"#,##0";
// not expected normally, id of a custom format should be greater
// than BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX
short poundFmtIdx = 6;
Assert.AreEqual(poundFmt, style.GetDataFormatString());
Assert.AreEqual(poundFmtIdx, style.DataFormat);
Assert.AreEqual("\u00a31", df.FormatCellValue(cell));
IDataFormat dataFormat = wb.CreateDataFormat();
Assert.AreEqual(poundFmtIdx, dataFormat.GetFormat(poundFmt));
Assert.AreEqual(poundFmt, dataFormat.GetFormat(poundFmtIdx));
}
示例10: TestTruthFile
public void TestTruthFile()
{
Stream truthFile = HSSFTestDataSamples.OpenSampleFileStream("54686_fraction_formats.txt");
TextReader reader = new StreamReader(truthFile);
IWorkbook wb = HSSFTestDataSamples.OpenSampleWorkbook("54686_fraction_formats.xls");
ISheet sheet = wb.GetSheetAt(0);
DataFormatter formatter = new DataFormatter();
IFormulaEvaluator Evaluator = wb.GetCreationHelper().CreateFormulaEvaluator();
// Skip over the header row
String truthLine = reader.ReadLine();
String[] headers = truthLine.Split("\t".ToCharArray());
truthLine = reader.ReadLine();
for (int i = 1; i < sheet.LastRowNum && truthLine != null; i++)
{
IRow r = sheet.GetRow(i);
String[] truths = truthLine.Split("\t".ToCharArray());
// Intentionally ignore the last column (tika-1132), for now
for (short j = 3; j < 12; j++)
{
ICell cell = r.GetCell(j, MissingCellPolicy.CREATE_NULL_AS_BLANK);
String truth = Clean(truths[j]);
String testKey = truths[0] + ":" + truths[1] + ":" + headers[j];
String formatted = Clean(formatter.FormatCellValue(cell, Evaluator));
if (truths.Length <= j)
{
continue;
}
Assert.AreEqual(truth, formatted, testKey);
}
truthLine = reader.ReadLine();
}
reader.Close();
}
示例11: TestElapsedTime
public void TestElapsedTime()
{
//DataFormatter dfUS = new DataFormatter(Locale.US);
DataFormatter dfUS = new DataFormatter(System.Globalization.CultureInfo.GetCultureInfo("en-US"));
double hour = 1.0 / 24.0;
Assert.AreEqual("01:00", dfUS.FormatRawCellContents(1 * hour, -1, "hh:mm"));
Assert.AreEqual("05:00", dfUS.FormatRawCellContents(5 * hour, -1, "hh:mm"));
Assert.AreEqual("20:00", dfUS.FormatRawCellContents(20 * hour, -1, "hh:mm"));
Assert.AreEqual("23:00", dfUS.FormatRawCellContents(23 * hour, -1, "hh:mm"));
Assert.AreEqual("00:00", dfUS.FormatRawCellContents(24 * hour, -1, "hh:mm"));
Assert.AreEqual("02:00", dfUS.FormatRawCellContents(26 * hour, -1, "hh:mm"));
Assert.AreEqual("20:00", dfUS.FormatRawCellContents(44 * hour, -1, "hh:mm"));
Assert.AreEqual("02:00", dfUS.FormatRawCellContents(50 * hour, -1, "hh:mm"));
Assert.AreEqual("01:00", dfUS.FormatRawCellContents(1 * hour, -1, "[hh]:mm"));
Assert.AreEqual("05:00", dfUS.FormatRawCellContents(5 * hour, -1, "[hh]:mm"));
Assert.AreEqual("20:00", dfUS.FormatRawCellContents(20 * hour, -1, "[hh]:mm"));
Assert.AreEqual("23:00", dfUS.FormatRawCellContents(23 * hour, -1, "[hh]:mm"));
Assert.AreEqual("24:00", dfUS.FormatRawCellContents(24 * hour, -1, "[hh]:mm"));
Assert.AreEqual("26:00", dfUS.FormatRawCellContents(26 * hour, -1, "[hh]:mm"));
Assert.AreEqual("44:00", dfUS.FormatRawCellContents(44 * hour, -1, "[hh]:mm"));
Assert.AreEqual("50:00", dfUS.FormatRawCellContents(50 * hour, -1, "[hh]:mm"));
Assert.AreEqual("01", dfUS.FormatRawCellContents(1 * hour, -1, "[hh]"));
Assert.AreEqual("05", dfUS.FormatRawCellContents(5 * hour, -1, "[hh]"));
Assert.AreEqual("20", dfUS.FormatRawCellContents(20 * hour, -1, "[hh]"));
Assert.AreEqual("23", dfUS.FormatRawCellContents(23 * hour, -1, "[hh]"));
Assert.AreEqual("24", dfUS.FormatRawCellContents(24 * hour, -1, "[hh]"));
Assert.AreEqual("26", dfUS.FormatRawCellContents(26 * hour, -1, "[hh]"));
Assert.AreEqual("44", dfUS.FormatRawCellContents(44 * hour, -1, "[hh]"));
Assert.AreEqual("50", dfUS.FormatRawCellContents(50 * hour, -1, "[hh]"));
double minute = 1.0 / 24.0 / 60.0;
Assert.AreEqual("01:00", dfUS.FormatRawCellContents(1 * minute, -1, "[mm]:ss"));
Assert.AreEqual("05:00", dfUS.FormatRawCellContents(5 * minute, -1, "[mm]:ss"));
Assert.AreEqual("20:00", dfUS.FormatRawCellContents(20 * minute, -1, "[mm]:ss"));
Assert.AreEqual("23:00", dfUS.FormatRawCellContents(23 * minute, -1, "[mm]:ss"));
Assert.AreEqual("24:00", dfUS.FormatRawCellContents(24 * minute, -1, "[mm]:ss"));
Assert.AreEqual("26:00", dfUS.FormatRawCellContents(26 * minute, -1, "[mm]:ss"));
Assert.AreEqual("44:00", dfUS.FormatRawCellContents(44 * minute, -1, "[mm]:ss"));
Assert.AreEqual("50:00", dfUS.FormatRawCellContents(50 * minute, -1, "[mm]:ss"));
Assert.AreEqual("59:00", dfUS.FormatRawCellContents(59 * minute, -1, "[mm]:ss"));
Assert.AreEqual("60:00", dfUS.FormatRawCellContents(60 * minute, -1, "[mm]:ss"));
Assert.AreEqual("61:00", dfUS.FormatRawCellContents(61 * minute, -1, "[mm]:ss"));
Assert.AreEqual("119:00", dfUS.FormatRawCellContents(119 * minute, -1, "[mm]:ss"));
Assert.AreEqual("120:00", dfUS.FormatRawCellContents(120 * minute, -1, "[mm]:ss"));
Assert.AreEqual("121:00", dfUS.FormatRawCellContents(121 * minute, -1, "[mm]:ss"));
Assert.AreEqual("01", dfUS.FormatRawCellContents(1 * minute, -1, "[mm]"));
Assert.AreEqual("05", dfUS.FormatRawCellContents(5 * minute, -1, "[mm]"));
Assert.AreEqual("20", dfUS.FormatRawCellContents(20 * minute, -1, "[mm]"));
Assert.AreEqual("23", dfUS.FormatRawCellContents(23 * minute, -1, "[mm]"));
Assert.AreEqual("24", dfUS.FormatRawCellContents(24 * minute, -1, "[mm]"));
Assert.AreEqual("26", dfUS.FormatRawCellContents(26 * minute, -1, "[mm]"));
Assert.AreEqual("44", dfUS.FormatRawCellContents(44 * minute, -1, "[mm]"));
Assert.AreEqual("50", dfUS.FormatRawCellContents(50 * minute, -1, "[mm]"));
Assert.AreEqual("59", dfUS.FormatRawCellContents(59 * minute, -1, "[mm]"));
Assert.AreEqual("60", dfUS.FormatRawCellContents(60 * minute, -1, "[mm]"));
Assert.AreEqual("61", dfUS.FormatRawCellContents(61 * minute, -1, "[mm]"));
Assert.AreEqual("119", dfUS.FormatRawCellContents(119 * minute, -1, "[mm]"));
Assert.AreEqual("120", dfUS.FormatRawCellContents(120 * minute, -1, "[mm]"));
Assert.AreEqual("121", dfUS.FormatRawCellContents(121 * minute, -1, "[mm]"));
double second = 1.0 / 24.0 / 60.0 / 60.0;
Assert.AreEqual("86400", dfUS.FormatRawCellContents(86400 * second, -1, "[ss]"));
Assert.AreEqual("01", dfUS.FormatRawCellContents(1 * second, -1, "[ss]"));
Assert.AreEqual("05", dfUS.FormatRawCellContents(5 * second, -1, "[ss]"));
Assert.AreEqual("20", dfUS.FormatRawCellContents(20 * second, -1, "[ss]"));
Assert.AreEqual("23", dfUS.FormatRawCellContents(23 * second, -1, "[ss]"));
Assert.AreEqual("24", dfUS.FormatRawCellContents(24 * second, -1, "[ss]"));
Assert.AreEqual("26", dfUS.FormatRawCellContents(26 * second, -1, "[ss]"));
Assert.AreEqual("44", dfUS.FormatRawCellContents(44 * second, -1, "[ss]"));
Assert.AreEqual("50", dfUS.FormatRawCellContents(50 * second, -1, "[ss]"));
Assert.AreEqual("59", dfUS.FormatRawCellContents(59 * second, -1, "[ss]"));
Assert.AreEqual("60", dfUS.FormatRawCellContents(60 * second, -1, "[ss]"));
Assert.AreEqual("61", dfUS.FormatRawCellContents(61 * second, -1, "[ss]"));
Assert.AreEqual("119", dfUS.FormatRawCellContents(119 * second, -1, "[ss]"));
Assert.AreEqual("120", dfUS.FormatRawCellContents(120 * second, -1, "[ss]"));
Assert.AreEqual("121", dfUS.FormatRawCellContents(121 * second, -1, "[ss]"));
//boolean jdk_1_5 = System.getProperty("java.vm.version").startsWith("1.5");
//if(!jdk_1_5) {
// YK: the tests below were written under JDK 1.6 and assume that
// the rounding mode in the underlying decimal formatters is HALF_UP
// It is not so JDK 1.5 where the default rounding mode is HALV_EVEN and cannot be changed.
Assert.AreEqual("27:18:08", dfUS.FormatRawCellContents(1.1376, -1, "[h]:mm:ss"));
Assert.AreEqual("28:48:00", dfUS.FormatRawCellContents(1.2, -1, "[h]:mm:ss"));
Assert.AreEqual("29:31:12", dfUS.FormatRawCellContents(1.23, -1, "[h]:mm:ss"));
Assert.AreEqual("31:26:24", dfUS.FormatRawCellContents(1.31, -1, "[h]:mm:ss"));
Assert.AreEqual("27:18:08", dfUS.FormatRawCellContents(1.1376, -1, "[hh]:mm:ss"));
Assert.AreEqual("28:48:00", dfUS.FormatRawCellContents(1.2, -1, "[hh]:mm:ss"));
Assert.AreEqual("29:31:12", dfUS.FormatRawCellContents(1.23, -1, "[hh]:mm:ss"));
Assert.AreEqual("31:26:24", dfUS.FormatRawCellContents(1.31, -1, "[hh]:mm:ss"));
Assert.AreEqual("57:07.2", dfUS.FormatRawCellContents(.123, -1, "mm:ss.0;@"));
Assert.AreEqual("57:41.8", dfUS.FormatRawCellContents(.1234, -1, "mm:ss.0;@"));
//.........这里部分代码省略.........
示例12: TestExcelStyleDateFormatterStringOnMillis
public void TestExcelStyleDateFormatterStringOnMillis()
{
// Test directly with the .000 style
SimpleDateFormat formatter1 = new ExcelStyleDateFormatter("ss.000");
CultureInfo culture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
DateTime dt = DateTime.Now.Date;
Assert.AreEqual("00.001", formatter1.Format(dt.AddMilliseconds(1L), culture));
Assert.AreEqual("00.010", formatter1.Format(dt.AddMilliseconds(10L), culture));
Assert.AreEqual("00.100", formatter1.Format(dt.AddMilliseconds(100L), culture));
Assert.AreEqual("01.000", formatter1.Format(dt.AddMilliseconds(1000L), culture));
Assert.AreEqual("01.001", formatter1.Format(dt.AddMilliseconds(1001L), culture));
Assert.AreEqual("10.000", formatter1.Format(dt.AddMilliseconds(10000L), culture));
Assert.AreEqual("10.001", formatter1.Format(dt.AddMilliseconds(10001L), culture));
// Test directly with the .SSS style
SimpleDateFormat formatter2 = new ExcelStyleDateFormatter("ss.fff");
Assert.AreEqual("00.001", formatter2.Format(dt.AddMilliseconds(1L), culture));
Assert.AreEqual("00.010", formatter2.Format(dt.AddMilliseconds(10L), culture));
Assert.AreEqual("00.100", formatter2.Format(dt.AddMilliseconds(100L), culture));
Assert.AreEqual("01.000", formatter2.Format(dt.AddMilliseconds(1000L), culture));
Assert.AreEqual("01.001", formatter2.Format(dt.AddMilliseconds(1001L), culture));
Assert.AreEqual("10.000", formatter2.Format(dt.AddMilliseconds(10000L), culture));
Assert.AreEqual("10.001", formatter2.Format(dt.AddMilliseconds(10001L), culture));
// Test via DataFormatter
DataFormatter dfUS = new DataFormatter(culture, true);
Assert.AreEqual("01.010", dfUS.FormatRawCellContents(0.0000116898, -1, "ss.000"));
}
示例13: TestBug54786
public void TestBug54786()
{
DataFormatter formatter = new DataFormatter();
String format = "[h]\"\"h\"\" m\"\"m\"\"";
Assert.IsTrue(DateUtil.IsADateFormat(-1, format));
Assert.IsTrue(DateUtil.IsValidExcelDate(_15_MINUTES));
Assert.AreEqual("1h 0m", formatter.FormatRawCellContents(_15_MINUTES, -1, format, false));
Assert.AreEqual("0.041666667", formatter.FormatRawCellContents(_15_MINUTES, -1, "[h]'h'", false));
Assert.AreEqual("1h 0m\"", formatter.FormatRawCellContents(_15_MINUTES, -1, "[h]\"\"h\"\" m\"\"m\"\"\"", false));
Assert.AreEqual("1h", formatter.FormatRawCellContents(_15_MINUTES, -1, "[h]\"\"h\"\"", false));
Assert.AreEqual("h1", formatter.FormatRawCellContents(_15_MINUTES, -1, "\"\"h\"\"[h]", false));
Assert.AreEqual("h1", formatter.FormatRawCellContents(_15_MINUTES, -1, "\"\"h\"\"h", false));
Assert.AreEqual(" 60", formatter.FormatRawCellContents(_15_MINUTES, -1, " [m]", false));
Assert.AreEqual("h60", formatter.FormatRawCellContents(_15_MINUTES, -1, "\"\"h\"\"[m]", false));
Assert.AreEqual("m1", formatter.FormatRawCellContents(_15_MINUTES, -1, "\"\"m\"\"h", false));
try
{
Assert.AreEqual("1h 0m\"", formatter.FormatRawCellContents(_15_MINUTES, -1, "[h]\"\"h\"\" m\"\"m\"\"\"\"", false));
Assert.Fail("Catches exception because of invalid format, i.e. trailing quoting");
}
catch (Exception e)
{
//Assert.IsTrue(e.Message.Contains("Cannot format given Object as a Number"));
}
}
示例14: TestPaddingSpacesCSV
public void TestPaddingSpacesCSV()
{
//DataFormatter dfUS = new DataFormatter(Locale.US);
DataFormatter dfUS = new DataFormatter(System.Globalization.CultureInfo.GetCultureInfo("en-US"), true);
Assert.AreEqual("12.34 ", dfUS.FormatRawCellContents(12.343, -1, "##.##_ "));
Assert.AreEqual("-12.34 ", dfUS.FormatRawCellContents(-12.343, -1, "##.##_ "));
Assert.AreEqual(". ", dfUS.FormatRawCellContents(0.0, -1, "##.##_ "));
Assert.AreEqual("12.34 ", dfUS.FormatRawCellContents(12.343, -1, "##.##_1"));
Assert.AreEqual("-12.34 ", dfUS.FormatRawCellContents(-12.343, -1, "##.##_1"));
Assert.AreEqual(". ", dfUS.FormatRawCellContents(0.0, -1, "##.##_1"));
Assert.AreEqual("12.34 ", dfUS.FormatRawCellContents(12.343, -1, "##.##_)"));
Assert.AreEqual("-12.34 ", dfUS.FormatRawCellContents(-12.343, -1, "##.##_)"));
Assert.AreEqual(". ", dfUS.FormatRawCellContents(0.0, -1, "##.##_)"));
Assert.AreEqual(" 12.34", dfUS.FormatRawCellContents(12.343, -1, "_-##.##"));
Assert.AreEqual("- 12.34", dfUS.FormatRawCellContents(-12.343, -1, "_-##.##"));
Assert.AreEqual(" .", dfUS.FormatRawCellContents(0.0, -1, "_-##.##"));
Assert.AreEqual("12.34", dfUS.FormatRawCellContents(12.343, -1, "##.##* "));
Assert.AreEqual("-12.34", dfUS.FormatRawCellContents(-12.343, -1, "##.##* "));
Assert.AreEqual(".", dfUS.FormatRawCellContents(0.0, -1, "##.##* "));
Assert.AreEqual("12.34", dfUS.FormatRawCellContents(12.343, -1, "##.##*1"));
Assert.AreEqual("-12.34", dfUS.FormatRawCellContents(-12.343, -1, "##.##*1"));
Assert.AreEqual(".", dfUS.FormatRawCellContents(0.0, -1, "##.##*1"));
Assert.AreEqual("12.34", dfUS.FormatRawCellContents(12.343, -1, "##.##*)"));
Assert.AreEqual("-12.34", dfUS.FormatRawCellContents(-12.343, -1, "##.##*)"));
Assert.AreEqual(".", dfUS.FormatRawCellContents(0.0, -1, "##.##*)"));
Assert.AreEqual("12.34", dfUS.FormatRawCellContents(12.343, -1, "*-##.##"));
Assert.AreEqual("-12.34", dfUS.FormatRawCellContents(-12.343, -1, "*-##.##"));
Assert.AreEqual(".", dfUS.FormatRawCellContents(0.0, -1, "*-##.##"));
}
示例15: TestErrors
public void TestErrors()
{
DataFormatter dfUS = new DataFormatter(System.Globalization.CultureInfo.GetCultureInfo("en-US"), true);
// Create a spreadsheet with some formula errors in it
IWorkbook wb = new HSSFWorkbook();
ISheet s = wb.CreateSheet();
IRow r = s.CreateRow(0);
ICell c = r.CreateCell(0, CellType.Error);
c.SetCellErrorValue(FormulaError.DIV0.Code);
Assert.AreEqual(FormulaError.DIV0.String, dfUS.FormatCellValue(c));
c.SetCellErrorValue(FormulaError.REF.Code);
Assert.AreEqual(FormulaError.REF.String, dfUS.FormatCellValue(c));
}