Example #1
0
        public void Write()
        {
            using (IExcelSpreadsheet spreadsheet = ExcelSpreadsheet.CreateNew(Filename))
            {
                using (IWorksheetWriter writer = spreadsheet.WriteToWorksheet("UnitTests"))
                {
                    Assert.That(writer.GetCurrentCell().Address, Is.EqualTo("A1"));
                    writer.Write("One");
                    Assert.That(writer.GetCurrentCell().Address, Is.EqualTo("B1"));

                    writer.MoveTo("D3");
                    writer.Write("New value at D3");
                    Assert.That(writer.GetCurrentCell().Address, Is.EqualTo("E3"));
                }
            }

            using (IExcelSpreadsheet spreadsheet = ExcelSpreadsheet.OpenReadOnly(Filename))
            {
                IWorksheetReader reader = spreadsheet.ReadWorksheet("UnitTests");
                reader.MoveTo("A1");
                Assert.That(reader.Read(), Is.EqualTo("One"));
                Assert.That(reader.GetCurrentCell().Address, Is.EqualTo("B1"));
                reader.MoveTo("D3");
                Assert.That(reader.Read(), Is.EqualTo("New value at D3"));
                Assert.That(reader.GetCurrentCell().Address, Is.EqualTo("E3"));
            }
        }
 private static void WriteRow(IWorksheetWriter writer, string address, int depth, string isa95Type, string isa95Class, string name)
 {
     writer.MoveTo(address);
     writer.Write(depth.ToString("0"));
     writer.Write(isa95Type);
     writer.Write(isa95Class);
     for (int i = 1; i < depth; i++)
     {
         writer.Write("");
     }
     writer.Write(name);
 }
Example #3
0
        private void Generate <T>(IEnumerable <T> items, ExcelColumn <T>[] columns, Stream outputStream)
        {
            var stream = _templateStream;

            try
            {
                using (var zip = ZipFile.Read(stream))
                {
                    zip.CompressionLevel = _compressionLevel;
                    zip.Strategy         = _compressionStrategy;

                    _worksheetWriter.Write(zip, items, columns);
                    _sharedStringsWriter.Write(zip);
                    _stylesWriter.Write(zip);

                    zip.Save(outputStream);
                }
            }
            catch (Exception)
            {
                if (_templateStream == null)
                {
                    stream?.Dispose();
                }
            }
        }
 private static void WriteRow(IWorksheetWriter writer, string address, params string[] values)
 {
     writer.MoveTo(address);
     foreach (string value in values)
     {
         writer.Write(value);
     }
 }
 private static void WriteRow(IWorksheetWriter writer, string address, params string[] values)
 {
     writer.MoveTo(address);
     foreach (string value in values)
     {
         writer.Write(value);
     }
 }
 private static void WriteRow(IWorksheetWriter writer, string address, int depth, string isa95Type, string isa95Class, string name)
 {
     writer.MoveTo(address);
     writer.Write(depth.ToString("0"));
     writer.Write(isa95Type);
     writer.Write(isa95Class);
     for (int i = 1; i < depth; i++)
     {
         writer.Write("");
     }
     writer.Write(name);
 }
 public void Write(string value)
 {
     writer.Write(value);
 }