public static void Main(string[] args)
        {
            WriteJavaDoc();

            HSSFWorkbook wb = new HSSFWorkbook();
            SheetWriter  sw = new SheetWriter(wb);

            NumberToTextConversionExamples.ExampleConversion[] exampleValues = NumberToTextConversionExamples.GetExampleConversions();
            for (int i = 0; i < exampleValues.Length; i++)
            {
                TestCases.SS.Util.NumberToTextConversionExamples.ExampleConversion example = exampleValues[i];
                sw.AddTestRow(example.RawDoubleBits, example.ExcelRendering);
            }

            MemoryStream baos = new MemoryStream();

            wb.Write(baos);
            byte[] fileContent = baos.ToArray();
            ReplaceNaNs(fileContent, sw.GetReplacementNaNs());


            FileInfo outputFile = new FileInfo("ExcelNumberRendering.xls");

            FileStream os = File.OpenWrite(outputFile.FullName);

            os.Write(fileContent, 0, fileContent.Length);
            os.Close();
            Console.WriteLine("Finished writing '" + outputFile.FullName + "'");
        }
        public static void WriteJavaDoc()
        {
            NumberToTextConversionExamples.ExampleConversion[] exampleConversions = NumberToTextConversionExamples.GetExampleConversions();
            for (int i = 0; i < exampleConversions.Length; i++)
            {
                NumberToTextConversionExamples.ExampleConversion ec = exampleConversions[i];
                string line = " * <tr><td>"
                              + FormatLongAsHex(ec.RawDoubleBits)
                              + "</td><td>" + ec.DoubleValue.ToString()
                              + "</td><td>" + ec.ExcelRendering + "</td></tr>";

                Console.WriteLine(line);
            }
        }
Beispiel #3
0
        public void TestAllNumberToText()
        {
            int failureCount = 0;

            NumberToTextConversionExamples.ExampleConversion[] examples = NumberToTextConversionExamples.GetExampleConversions();

            for (int i = 0; i < examples.Length; i++)
            {
                NumberToTextConversionExamples.ExampleConversion example = examples[i];
                try
                {
                    if (example.IsNaN)
                    {
                        ConfirmNaN(example.RawDoubleBits, example.ExcelRendering);
                        continue;
                    }

                    String actual = NumberToTextConverter.ToText(example.DoubleValue);

                    if (!example.ExcelRendering.Equals(actual))
                    {
                        failureCount++;
                        String msg = "Error rendering for examples[" + i + "] "
                                     + FormatExample(example) + " "
                                     + " bad-result='" + actual + "' "
                                     + "Excel String=" + example.ExcelRendering;
                        Console.WriteLine(msg);
                    }
                }
                catch (Exception e)
                {
                    failureCount++;
                    Console.WriteLine("Error in excel rendering for examples[" + i + "] "
                                      + FormatExample(example) + "':" + e.Message);
                    Console.Write(e.StackTrace);
                }
            }

            if (failureCount > 0)
            {
                throw new Exception(failureCount
                                    + " error(s) in excel number to text conversion (see std-err)");
            }
        }