public string GetResult(int columnCount, params object[] values)
 {
     using (var stream = new MemoryStream())
     {
         using (var writer = new SpreadsheetWriter(stream))
         {
             writer.WriteSpreedsheat(new SpreadsheetProcessingResult(columnCount, values));
             stream.Position = 0;
             return(Encoding.UTF8.GetString(stream.ToArray()));
         }
     }
 }
Example #2
0
 private static string Evaluate(string data)
 {
     using (var reader = new SpreadsheetReader(new StringReader(data)))
     {
         using (var ms = new MemoryStream())
         {
             using (var writer = new SpreadsheetWriter(ms))
             {
                 writer.WriteSpreedsheat(new SpreadsheetProcessor(reader.ReadSpreadsheet()).Evaluate(new ParallelProcessingStrategy()));
                 return(Encoding.UTF8.GetString(ms.ToArray()));
             }
         }
     }
 }
Example #3
0
        static void Main(string[] args)
        {
            var isConsoleInput  = args.Length < 1;
            var isConsoleOutput = args.Length < 2;

            try
            {
                var input  = isConsoleInput ? Console.OpenStandardInput() : File.Open(args[0], FileMode.Open);
                var output = isConsoleOutput ? Console.OpenStandardOutput() : File.Create(args[1]);
                using (var reader = new SpreadsheetReader(input))
                {
                    Console.WriteLine(isConsoleInput ? Resources.EnterTable : Resources.ReadingTable);
                    var spreadsheet = reader.ReadSpreadsheet();

                    Console.WriteLine(Resources.Processing);
                    var processor = new SpreadsheetProcessor(spreadsheet);
                    var result    = processor.Evaluate(new ParallelProcessingStrategy());

                    Console.WriteLine(isConsoleOutput ? Resources.ResultTable : Resources.WritingResult);
                    using (var write = new SpreadsheetWriter(output))
                    {
                        write.WriteSpreedsheat(result);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }

            if (isConsoleOutput)
            {
                Console.Write(Resources.PressAnyKeyForExit);
                Console.ReadKey();
            }
        }