diff --git a/ooxml/XSSF/Streaming/SheetDataWriter.cs b/ooxml/XSSF/Streaming/SheetDataWriter.cs index 270ac1762..fd0c7f9bc 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); @@ -218,13 +217,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 b2778ca25..28ed9daee 100644 --- a/testcases/ooxml/XSSF/Streaming/SheetDataWriterTests.cs +++ b/testcases/ooxml/XSSF/Streaming/SheetDataWriterTests.cs @@ -64,8 +64,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(); @@ -73,7 +74,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]); @@ -93,7 +94,7 @@ public void IfWritingRowWithZeroHeightShouldIncludeHiddenAttributeXml() var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 2); - Assert.AreEqual("