diff --git a/ooxml/XSSF/Streaming/SheetDataWriter.cs b/ooxml/XSSF/Streaming/SheetDataWriter.cs index c8098be2f..86a814326 100644 --- a/ooxml/XSSF/Streaming/SheetDataWriter.cs +++ b/ooxml/XSSF/Streaming/SheetDataWriter.cs @@ -18,7 +18,6 @@ limitations under the License. using System.Globalization; using System.IO; using System.Text; -using NPOI.OpenXmlFormats.Spreadsheet; using NPOI.SS.UserModel; using NPOI.SS.Util; using NPOI.Util; @@ -29,7 +28,7 @@ namespace NPOI.XSSF.Streaming { public class SheetDataWriter { - private static POILogger logger = POILogFactory.GetLogger(typeof(SheetDataWriter)); + private static readonly POILogger logger = POILogFactory.GetLogger(typeof(SheetDataWriter)); protected FileInfo TemporaryFileInfo { get; set; } protected Stream OutputStream { get; private set; } @@ -43,8 +42,8 @@ public class SheetDataWriter * Table of strings shared across this workbook. * If two cells contain the same string, then the cell value is the same index into SharedStringsTable */ - private SharedStringsTable _sharedStringSource; - private StreamWriter _outputWriter; + private readonly SharedStringsTable _sharedStringSource; + private readonly StreamWriter _outputWriter; public SheetDataWriter() { @@ -79,7 +78,7 @@ public virtual Stream CreateWriter(FileInfo fd) { FileStream fos = new FileStream(fd.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite); - Stream outputStream = null; + Stream outputStream; try { outputStream = DecorateOutputStream(fos); @@ -228,13 +227,13 @@ private void BeginRow(int rownum, SXSSFRow row) if (row.HasCustomHeight()) { - WriteAsBytes(" customHeight=\"true\" ht=\""); + WriteAsBytes(" customHeight=\"1\" ht=\""); WriteAsBytes(row.HeightInPoints); WriteAsBytes("\""); } if (row.ZeroHeight) { - WriteAsBytes(" hidden=\"true\""); + WriteAsBytes(" hidden=\"1\""); } if (row.IsFormatted) { diff --git a/testcases/ooxml/XSSF/Streaming/SheetDataWriterTests.cs b/testcases/ooxml/XSSF/Streaming/SheetDataWriterTests.cs index ca504036a..379ee7ada 100644 --- a/testcases/ooxml/XSSF/Streaming/SheetDataWriterTests.cs +++ b/testcases/ooxml/XSSF/Streaming/SheetDataWriterTests.cs @@ -65,8 +65,9 @@ public void IfCallingEmptyConstructorShouldCreateNonZippedTempFileNonDecoratedSt public void IfWritingRowWithCustomHeightShouldIncludeCustomHeightXml() { _objectToTest = new SheetDataWriter(); - var row = new SXSSFRow(null); - row.Height = 1; + var row = new SXSSFRow(null) { + Height = 1 + }; _objectToTest.WriteRow(0, row); _objectToTest.Close(); @@ -74,7 +75,7 @@ public void IfWritingRowWithCustomHeightShouldIncludeCustomHeightXml() var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 2); - Assert.AreEqual("", lines[0]); + Assert.AreEqual("", lines[0]); Assert.AreEqual("", lines[1]); @@ -94,7 +95,7 @@ public void IfWritingRowWithZeroHeightShouldIncludeHiddenAttributeXml() var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 2); - Assert.AreEqual("