Esempio n. 1
0
        public void Should_encode_without_description()
        {
            // given
            var cmds = _simpleCmds;
            // when
            var doc = ExcelService.Encode(false, cmds);

            // then
            Check.That(doc).IsEqualTo("^q=AQAAAAJBMQEAAmYx");
        }
Esempio n. 2
0
        public void Should_encode_with_description()
        {
            // given
            var cmds = _simpleCmds;
            // when
            var doc = ExcelService.Encode(true, cmds);

            // then
            Check.That(doc).IsEqualTo(
                @"^q|   CellsStyle[A1]: f1
^q=AQAAAAJBMQEAAmYx".ToLocalString());
        }
Esempio n. 3
0
        public void Should_decode_correctly()
        {
            // given
            var value  = "^q=AQAAAAJBMQEAAmYx";
            var value2 = ExcelService.Encode(false, _simpleCmds);
            // when
            var cmds  = ExcelService.Decode(value);
            var cmds2 = ExcelService.Decode(value2);

            // then
            Check.That(cmds.Select(x => ((CellStyle)x).Cells)).IsEquivalentTo(_simpleCmds.Select(x => ((CellStyle)x).Cells));
            Check.That(cmds2.Select(x => ((CellStyle)x).Cells)).IsEquivalentTo(_simpleCmds.Select(x => ((CellStyle)x).Cells));
        }
Esempio n. 4
0
        static Tuple <Stream, string, string> MakeInvoiceFile(IEnumerable <TestData> myData)
        {
            var transform = ExcelService.Encode(new List <IExcelCommand>
            {
                new WorksheetsAdd("Invoice"),
                new CellsStyle(Address.Range, 0, 1, 2, 1, "lc:Yellow"),
            });

            var s = new MemoryStream();
            var w = new StreamWriter(s);

            // add transform to output
            w.WriteLine(transform);
            // add csv file to output
            CsvWriter.Write(w, myData);
            w.Flush(); s.Position = 0;
            var result = new Tuple <Stream, string, string>(s, "text/csv", "invoice.csv");

            // optionally transform
            result = ExcelService.Transform(result);
            return(result);
        }