Repository: nissl-lab/npoi (2026-04-01T20:54:56Z)

Issue:
ISheet.SetDefaultColumnStyle not applied to new cells
Hi, I'm creating a new sheet with a header row and then the data, I'm trying to apply default style to the whole column, so all the rows after the header will have the same style.

Here's my code:
```csharp
var sheet = workbook.CreateSheet(sheetName);

// Create header
var rowIndex = 0;
var columnIndex = 0;
var properties = entityType.GetPropertiesOrdered();
var row = sheet.CreateRow(rowIndex++);
foreach (var property in properties) {
  var cell = row.CreateCell(columnIndex);
  cell.CellStyle = (...);
  cell.SetCellValue(property.Name);
  
  sheet.SetDefaultColumnStyle(columnIndex, styles.Default); // Here I set the default style
  
  columnIndex++;
}

// Populate rows
foreach (var dataRow in rows) {
  row = sheet.CreateRow(rowIndex++);
  columnIndex = 0;
  foreach (var property in properties) {
    var cell = row.CreateCell(columnIndex++);

    //cell.CellStyle = styles.Default;

    cell.SetCellValue(...);
  }
}

workbook.Write(..., true);
```

But this way the cells are not styled, if I instead apply the style manually (by uncommenting the code above) to all the cells then it works.


Discussion:
Is this file xlsx?
> Is this file xlsx?

Yep
It doesn't work at all on column level:

```csharp
// Create a new workbook
var workbook = new XSSFWorkbook();
// Create a new sheet
var sheet = workbook.CreateSheet("gridExport_0");

//// Create a style for the rows
var style = workbook.CreateCellStyle();

// Create a solid foreground fill
style.FillPattern = FillPattern.SolidForeground;
style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.SkyBlue.Index; // Set the foreground color
style.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Black.Index; // Set the background color

var datetimeStyle = workbook.CreateCellStyle();
var        dataformat = workbook.CreateDataFormat();
datetimeStyle.DataFormat = dataformat.GetFormat("yyyy-MM-dd HH:mm:ss");

// Applying the style to the first row (index 0)
sheet.SetDefaultColumnStyle(0, datetimeStyle);
sheet.SetDefaultColumnStyle(1, datetimeStyle);
var row = sheet.CreateRow(0);
row.RowStyle = style;
var cell = row.CreateCell(0);
cell.SetCellType(CellType.String);
cell.SetCellValue("date1");
cell = row.CreateCell(1);
sheet.SetDefaultColumnStyle(1, datetimeStyle);
cell.SetCellType(CellType.String);
cell.SetCellValue("Date2");

row = sheet.CreateRow(1);
cell = row.CreateCell(0);
cell.SetCellType(CellType.Numeric);
cell.SetCellValue(DateTime.UtcNow);
cell = row.CreateCell(1);
sheet.SetDefaultColumnStyle(1, datetimeStyle);
cell.SetCellType(CellType.Numeric);
cell.SetCellValue(DateTime.UtcNow);
//cell.CellStyle = datetimeStyle;

//create file
using var file = new FileStream("/app/test.xlsx", FileMode.Create, FileAccess.Write);
workbook.Write(file);
```
[POI Bug 51037](https://bz.apache.org/bugzilla/show_bug.cgi?id=51037)
https://github.com/apache/poi/pull/406 PR should be applied too, because fix in https://github.com/apache/poi/pull/338 cause performance issue
> [POI Bug 51037](https://bz.apache.org/bugzilla/show_bug.cgi?id=51037)

I have met same trouble,Is this bug fixed in 2.7.1?
> > [POI Bug 51037](https://bz.apache.org/bugzilla/show_bug.cgi?id=51037)
> 
> I have met same trouble,Is this bug fixed in 2.7.1?

HI, unfortunately, no. I've tried to create a PR, but some of the tests are failing. You can contribute if you wish: https://github.com/nissl-lab/npoi/pull/1340
> HI, unfortunately, no. I've tried to create a PR, but some of the tests are failing. You can contribute if you wish: #1340

That PR was closed, is there a reason? Has a fix already been applied by another PR 🤞
> > HI, unfortunately, no. I've tried to create a PR, but some of the tests are failing. You can contribute if you wish: #1340
> 
> That PR was closed, is there a reason? Has a fix already been applied by another PR 🤞

There was an issue with failing unit tests, help is appreciated
/oc  help recreate the PR based on PR #1340 and see if there is any other issue
- https://github.com/apache/poi/pull/338/
Created PR #1780

<a href="https://opencode.ai/s/rTgkVzqY"><img width="200" alt="New%20session%20-%202026-04-01T20%3A20%3A04.414Z" src="https://social-cards.sst.dev/opencode-share/TmV3IHNlc3Npb24gLSAyMDI2LTA0LTAxVDIwOjIwOjA0LjQxNFo=.png?model=opencode/big-pickle&version=1.3.13&id=rTgkVzqY" /></a>
[opencode session](https://opencode.ai/s/rTgkVzqY)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/nissl-lab/npoi/actions/runs/23868946589)
/oc sync code from https://github.com/apache/poi/pull/338/ to NPOI (Java to C#)
Created PR #1781

<a href="https://opencode.ai/s/eMJnqOgP"><img width="200" alt="New%20session%20-%202026-04-01T20%3A48%3A36.751Z" src="https://social-cards.sst.dev/opencode-share/TmV3IHNlc3Npb24gLSAyMDI2LTA0LTAxVDIwOjQ4OjM2Ljc1MVo=.png?model=opencode/big-pickle&version=1.3.13&id=eMJnqOgP" /></a>
[opencode session](https://opencode.ai/s/eMJnqOgP)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/nissl-lab/npoi/actions/runs/23870132445)



Patch:
diff --git a/main/SS/Util/CellUtil.cs b/main/SS/Util/CellUtil.cs
index 96c853fa0e..d01e35e8ad 100644
--- a/main/SS/Util/CellUtil.cs
+++ b/main/SS/Util/CellUtil.cs
@@ -585,6 +585,11 @@ private static void PutAll(Dictionary<String, Object> src, Dictionary<String, Ob
          */
         private static Dictionary<String, Object> GetFormatProperties(ICellStyle style)
         {
+            if (style == null)
+            {
+                return new Dictionary<String, Object>();
+            }
+
             Dictionary<String, Object> properties = new Dictionary<String, Object>();
             Put(properties, ALIGNMENT, style.Alignment);
             Put(properties, VERTICAL_ALIGNMENT, style.VerticalAlignment);
@@ -652,7 +657,10 @@ private static void SetFormatProperties(ICellStyle style, IWorkbook workbook, Di
          */
         private static short GetShort(Dictionary<String, Object> properties, String name)
         {
-            Object value = properties[name];
+            if (!properties.TryGetValue(name, out var value) || value == null)
+            {
+                return 0;
+            }
             short result = 0;
             if (short.TryParse(value.ToString(), out result))
                 return result;
@@ -669,7 +677,10 @@ private static short GetShort(Dictionary<String, Object> properties, String name
          */
         private static int GetInt(Dictionary<String, Object> properties, String name)
         {
-            Object value = properties[name];
+            if (!properties.TryGetValue(name, out var value))
+            {
+                return 0;
+            }
             if (Number.IsNumber(value))
             {
                 return int.Parse(value.ToString());
@@ -686,7 +697,10 @@ private static int GetInt(Dictionary<String, Object> properties, String name)
          */
         private static BorderStyle GetBorderStyle(Dictionary<String, Object> properties, String name)
         {
-            Object value = properties[name];
+            if (!properties.TryGetValue(name, out var value))
+            {
+                return BorderStyle.None;
+            }
             BorderStyle border;
             if (value is BorderStyle style)
             {
@@ -724,7 +738,10 @@ private static BorderStyle GetBorderStyle(Dictionary<String, Object> properties,
          */
         private static FillPattern GetFillPattern(Dictionary<String, Object> properties, String name)
         {
-            Object value = properties[name];
+            if (!properties.TryGetValue(name, out var value))
+            {
+                return FillPattern.NoFill;
+            }
             FillPattern pattern;
             if (value is FillPattern fillPattern)
             {
@@ -761,7 +778,10 @@ private static FillPattern GetFillPattern(Dictionary<String, Object> properties,
          */
         private static HorizontalAlignment GetHorizontalAlignment(Dictionary<String, Object> properties, String name)
         {
-            Object value = properties[name];
+            if (!properties.TryGetValue(name, out var value))
+            {
+                return HorizontalAlignment.General;
+            }
             HorizontalAlignment align;
             if (value is HorizontalAlignment alignment)
             {
@@ -798,7 +818,10 @@ private static HorizontalAlignment GetHorizontalAlignment(Dictionary<String, Obj
          */
         private static VerticalAlignment GetVerticalAlignment(Dictionary<String, Object> properties, String name)
         {
-            Object value = properties[name];
+            if (!properties.TryGetValue(name, out var value))
+            {
+                return VerticalAlignment.Bottom;
+            }
             VerticalAlignment align;
             if (value is VerticalAlignment alignment)
             {
@@ -834,7 +857,10 @@ private static VerticalAlignment GetVerticalAlignment(Dictionary<String, Object>
          */
         private static bool GetBoolean(Dictionary<String, Object> properties, String name)
         {
-            Object value = properties[name];
+            if (!properties.TryGetValue(name, out var value) || value == null)
+            {
+                return false;
+            }
             bool result = false;
             if (bool.TryParse(value.ToString(), out result))
                 return result;
diff --git a/ooxml/XSSF/Streaming/SXSSFCell.cs b/ooxml/XSSF/Streaming/SXSSFCell.cs
index ac4bc3c3c3..d1646327e9 100644
--- a/ooxml/XSSF/Streaming/SXSSFCell.cs
+++ b/ooxml/XSSF/Streaming/SXSSFCell.cs
@@ -175,8 +175,13 @@ public ICellStyle CellStyle
             {
                 if (_style == null)
                 {
-                    SXSSFWorkbook wb = (SXSSFWorkbook)Row.Sheet.Workbook;
-                    return wb.GetCellStyleAt(0);
+                    ICellStyle style = GetDefaultCellStyleFromColumn();
+                    if (style == null)
+                    {
+                        SXSSFWorkbook wb = (SXSSFWorkbook)Sheet.Workbook;
+                        style = wb.GetCellStyleAt(0);
+                    }
+                    return style;
                 }
                 else
                 {
@@ -190,6 +195,16 @@ public ICellStyle CellStyle
             }
         }
 
+        private ICellStyle GetDefaultCellStyleFromColumn()
+        {
+            ICellStyle style = null;
+            SXSSFSheet sheet = (SXSSFSheet)Sheet;
+            if (sheet != null)
+            {
+                style = sheet.GetColumnStyle(ColumnIndex);
+            }
+            return style;
+        }
         public ICellStyle Style
         {
             get
diff --git a/ooxml/XSSF/UserModel/Helpers/ColumnHelper.cs b/ooxml/XSSF/UserModel/Helpers/ColumnHelper.cs
index 5a4ba77cfd..c59a60ba8c 100644
--- a/ooxml/XSSF/UserModel/Helpers/ColumnHelper.cs
+++ b/ooxml/XSSF/UserModel/Helpers/ColumnHelper.cs
@@ -125,6 +125,10 @@ public CT_Col GetColumn(long index, bool splitColumns)
         /// <returns></returns>
         public CT_Col GetColumn1Based(long index1, bool splitColumns)
         {
+            if (worksheet.sizeOfColsArray() == 0)
+            {
+                return null;
+            }
             CT_Cols colsArray = worksheet.GetColsArray(0);
 
             // Fetching the array is quicker than working on the new style
diff --git a/ooxml/XSSF/UserModel/XSSFCell.cs b/ooxml/XSSF/UserModel/XSSFCell.cs
index 18a26b293b..f741f05e28 100644
--- a/ooxml/XSSF/UserModel/XSSFCell.cs
+++ b/ooxml/XSSF/UserModel/XSSFCell.cs
@@ -707,21 +707,30 @@ public CellAddress Address
             }
         }
         /// <summary>
-        /// Return the cell's style.
+        /// Get the cell style. This is a reference to a cell style contained in the workbook
+        /// object. If there is no explicit cell style, the default style is returned.
+        /// cell has no style of its own. If no column default style is set, the row default style is checked.
+        /// This method has always fallen back to return the default style
+        /// if there is no other style to return.
         /// </summary>
         public ICellStyle CellStyle
         {
             get
             {
-                XSSFCellStyle style = null;
-                if ((null != _stylesSource) && (_stylesSource.NumCellStyles > 0))
+                XSSFCellStyle style = GetExplicitCellStyle();
+                if (style == null)
                 {
-                    long idx = _cell.IsSetS() ? _cell.s : 0;
-                    style = _stylesSource.GetStyleAt((int)idx);
+                    style = GetDefaultCellStyleFromColumn();
+                }
+                // Return default style at index 0 if no explicit or column style exists
+                // This matches HSSFCell behavior which always returns a non-null style
+                if (style == null && _stylesSource != null)
+                {
+                    style = _stylesSource.GetStyleAt(0);
                 }
                 return style;
             }
-            set 
+            set
             {
                 if (value == null)
                 {
@@ -738,6 +747,47 @@ public ICellStyle CellStyle
             }
         }
 
+        private XSSFCellStyle GetExplicitCellStyle()
+        {
+            XSSFCellStyle style = null;
+            if (_stylesSource != null && _stylesSource.NumCellStyles > 0)
+            {
+                if (_cell.IsSetS())
+                {
+                    long idx = _cell.s;
+                    style = _stylesSource.GetStyleAt((int)idx);
+                }
+            }
+            return style;
+        }
+
+        private XSSFCellStyle GetDefaultCellStyleFromColumn()
+        {
+            XSSFCellStyle style = null;
+            XSSFSheet sheet = (XSSFSheet)Sheet;
+            if (sheet != null)
+            {
+                style = (XSSFCellStyle)sheet.GetColumnStyle(ColumnIndex);
+            }
+            return style;
+        }
+
+        internal void ApplyDefaultCellStyleIfNecessary()
+        {
+            XSSFCellStyle style = GetExplicitCellStyle();
+            if (style == null)
+            {
+                XSSFSheet sheet = (XSSFSheet)Sheet;
+                if (sheet != null)
+                {
+                    XSSFCellStyle defaultStyle = GetDefaultCellStyleFromColumn();
+                    if (defaultStyle != null)
+                    {
+                        CellStyle = defaultStyle;
+                    }
+                }
+            }
+        }
         public ICellStyle Style
         {
             get
diff --git a/ooxml/XSSF/UserModel/XSSFRow.cs b/ooxml/XSSF/UserModel/XSSFRow.cs
index c196e1bafa..b89038e792 100644
--- a/ooxml/XSSF/UserModel/XSSFRow.cs
+++ b/ooxml/XSSF/UserModel/XSSFRow.cs
@@ -569,6 +569,11 @@ internal void OnDocumentWrite()
         {
             var sortedCells = GetSortedCells();
 
+            foreach (XSSFCell cell in sortedCells.Cast<XSSFCell>())
+            {
+                cell.ApplyDefaultCellStyleIfNecessary();
+            }
+
             bool isOrdered = true;
             if (_row.SizeOfCArray() != _cells.Count)
             {
diff --git a/ooxml/XSSF/UserModel/XSSFSheet.cs b/ooxml/XSSF/UserModel/XSSFSheet.cs
index 3ee019469a..0e6c90a92b 100644
--- a/ooxml/XSSF/UserModel/XSSFSheet.cs
+++ b/ooxml/XSSF/UserModel/XSSFSheet.cs
@@ -3456,10 +3456,14 @@ public ICellStyle GetColumnStyle(int column)
 
             if(col != null)
             {
-                return col.ColumnStyle;
+                ICellStyle style = col.ColumnStyle;
+                if (style != null)
+                {
+                    return style;
+                }
             }
 
-            return Workbook.GetCellStyleAt(0);
+            return ((XSSFWorkbook)Workbook).GetCellStyleAt(0);
         }
 
         /// <summary>


Test patch:
diff --git a/testcases/main/SS/UserModel/BaseTestBorderStyle.cs b/testcases/main/SS/UserModel/BaseTestBorderStyle.cs
index 678689dbd9..ecf60a59f2 100644
--- a/testcases/main/SS/UserModel/BaseTestBorderStyle.cs
+++ b/testcases/main/SS/UserModel/BaseTestBorderStyle.cs
@@ -75,7 +75,10 @@ private ICell GetDiagonalCell(ISheet sheet, int n)
 
         protected void AssertBorderStyleEquals(BorderStyle expected, ICell cell)
         {
+            System.Diagnostics.Debug.WriteLine($"DEBUG: cell.CellStyle called for row={cell.RowIndex}, col={cell.ColumnIndex}");
             ICellStyle style = cell.CellStyle;
+            System.Diagnostics.Debug.WriteLine($"DEBUG: cell.CellStyle returned: {(style == null ? "null" : style.GetType().Name)}");
+            ClassicAssert.IsNotNull(style, "CellStyle should not be null");
             ClassicAssert.AreEqual(expected, style.BorderTop);
             ClassicAssert.AreEqual(expected, style.BorderBottom);
             ClassicAssert.AreEqual(expected, style.BorderLeft);
diff --git a/testcases/main/SS/UserModel/BaseTestSheet.cs b/testcases/main/SS/UserModel/BaseTestSheet.cs
index 1f09e2768b..eb573ea6e0 100644
--- a/testcases/main/SS/UserModel/BaseTestSheet.cs
+++ b/testcases/main/SS/UserModel/BaseTestSheet.cs
@@ -722,8 +722,8 @@ public virtual void Bug35084()
 
             wb.Close();
         }
-        [Ignore("not sure why style not match")]
-        /** Test that new default column styles Get applied */
+        [Test]
+        /** Test that new default column styles get applied */
         public virtual void DefaultColumnStyle()
         {
             IWorkbook wb = _testDataProvider.CreateWorkbook();
@@ -737,9 +737,21 @@ public virtual void DefaultColumnStyle()
             ICell cell = row.CreateCell(0);
             ICellStyle style2 = cell.CellStyle;
             ClassicAssert.IsNotNull(style2);
-            ClassicAssert.AreEqual(style.Index, style2.Index, "style should match");
+            ClassicAssert.AreEqual(style.Index, style2.Index, "style2 should match");
 
+            IWorkbook wb2 = _testDataProvider.WriteOutAndReadBack(wb);
             wb.Close();
+            ISheet wb2Sheet = wb2.GetSheetAt(0);
+            ClassicAssert.IsNotNull(wb2Sheet.GetColumnStyle(0));
+            ClassicAssert.AreEqual(style.Index, wb2Sheet.GetColumnStyle(0).Index);
+
+            IRow wb2R0 = wb2Sheet.GetRow(0);
+            ICell wb2Cell = wb2R0.GetCell(0);
+            ICellStyle style3 = wb2Cell.CellStyle;
+            ClassicAssert.IsNotNull(style3);
+            ClassicAssert.AreEqual(style.Index, style3.Index, "style3 should match");
+
+            wb2.Close();
         }
         [Test]
         public void TestOutlineProperties()
diff --git a/testcases/ooxml/XSSF/Streaming/TestSXSSFBugs.cs b/testcases/ooxml/XSSF/Streaming/TestSXSSFBugs.cs
index 02380db286..04847c4d56 100644
--- a/testcases/ooxml/XSSF/Streaming/TestSXSSFBugs.cs
+++ b/testcases/ooxml/XSSF/Streaming/TestSXSSFBugs.cs
@@ -3,6 +3,7 @@
 using NPOI.Util;
 using NPOI.XSSF;
 using NPOI.XSSF.Streaming;
+using NPOI.XSSF.UserModel;
 using NUnit.Framework;using NUnit.Framework.Legacy;
 using System.IO;
 using TestCases.SS.UserModel;
@@ -83,5 +84,54 @@ public void bug60197_NamedRangesReferToCorrectSheetWhenSheetOrderIsChanged()
                 }
             }
         }
+
+        [Test]
+        public void Test51037()
+        {
+            using (SXSSFWorkbook wb = new SXSSFWorkbook())
+            {
+                ICellStyle blueStyle = wb.CreateCellStyle();
+                blueStyle.FillForegroundColor = IndexedColors.Aqua.Index;
+                blueStyle.FillPattern = FillPattern.SolidForeground;
+
+                ICellStyle pinkStyle = wb.CreateCellStyle();
+                pinkStyle.FillForegroundColor = IndexedColors.Pink.Index;
+                pinkStyle.FillPattern = FillPattern.SolidForeground;
+
+                ISheet s1 = wb.CreateSheet("Pretty columns");
+
+                s1.SetDefaultColumnStyle(4, blueStyle);
+                s1.SetDefaultColumnStyle(6, pinkStyle);
+
+                IRow r3 = s1.CreateRow(3);
+                r3.CreateCell(0).SetCellValue("The");
+                r3.CreateCell(1).SetCellValue("quick");
+                r3.CreateCell(2).SetCellValue("brown");
+                r3.CreateCell(3).SetCellValue("fox");
+                r3.CreateCell(4).SetCellValue("jumps");
+                r3.CreateCell(5).SetCellValue("over");
+                r3.CreateCell(6).SetCellValue("the");
+                r3.CreateCell(7).SetCellValue("lazy");
+                r3.CreateCell(8).SetCellValue("dog");
+                IRow r7 = s1.CreateRow(7);
+                r7.CreateCell(1).CellStyle = pinkStyle;
+                r7.CreateCell(8).CellStyle = blueStyle;
+
+                ClassicAssert.AreEqual(blueStyle.Index, r3.GetCell(4).CellStyle.Index);
+                ClassicAssert.AreEqual(pinkStyle.Index, r3.GetCell(6).CellStyle.Index);
+
+                using (MemoryStream bos = new MemoryStream())
+                {
+                    wb.Write(bos);
+                    using (XSSFWorkbook wb2 = new XSSFWorkbook(new MemoryStream(bos.ToArray())))
+                    {
+                        XSSFSheet wb2Sheet = (XSSFSheet)wb2.GetSheetAt(0);
+                        XSSFRow wb2R3 = (XSSFRow)wb2Sheet.GetRow(3);
+                        ClassicAssert.AreEqual(blueStyle.Index, wb2R3.GetCell(4).CellStyle.Index);
+                        ClassicAssert.AreEqual(pinkStyle.Index, wb2R3.GetCell(6).CellStyle.Index);
+                    }
+                }
+            }
+        }
     }
 }
diff --git a/testcases/ooxml/XSSF/Streaming/TestSXSSFSheet.cs b/testcases/ooxml/XSSF/Streaming/TestSXSSFSheet.cs
index f4a6562cf8..09530b907b 100644
--- a/testcases/ooxml/XSSF/Streaming/TestSXSSFSheet.cs
+++ b/testcases/ooxml/XSSF/Streaming/TestSXSSFSheet.cs
@@ -111,10 +111,6 @@ public override void GetCellComment() {
             // properties on Cells...
         }
 
-        public override void DefaultColumnStyle() {
-            //TODO column styles are not yet supported by XSSF
-        }
-
         [Test]
         public void OverrideFlushedRows() {
             IWorkbook wb = new SXSSFWorkbook(3);
diff --git a/testcases/ooxml/XSSF/UserModel/TestXSSFBugs.cs b/testcases/ooxml/XSSF/UserModel/TestXSSFBugs.cs
index dd7d586484..eb5f863878 100644
--- a/testcases/ooxml/XSSF/UserModel/TestXSSFBugs.cs
+++ b/testcases/ooxml/XSSF/UserModel/TestXSSFBugs.cs
@@ -3688,5 +3688,50 @@ public void Test64986()
             ClassicAssert.AreEqual(CellType.Numeric, value.CellType);
             ClassicAssert.AreEqual(1, value.NumberValue, 0.01);
         }
+
+        [Test]
+        public void Test51037()
+        {
+            using (XSSFWorkbook wb = new XSSFWorkbook())
+            {
+                XSSFCellStyle blueStyle = (XSSFCellStyle)wb.CreateCellStyle();
+                blueStyle.FillForegroundColor = IndexedColors.Aqua.Index;
+                blueStyle.FillPattern = FillPattern.SolidForeground;
+
+                XSSFCellStyle pinkStyle = (XSSFCellStyle)wb.CreateCellStyle();
+                pinkStyle.FillForegroundColor = IndexedColors.Pink.Index;
+                pinkStyle.FillPattern = FillPattern.SolidForeground;
+
+                ISheet s1 = wb.CreateSheet("Pretty columns");
+
+                s1.SetDefaultColumnStyle(4, blueStyle);
+                s1.SetDefaultColumnStyle(6, pinkStyle);
+
+                IRow r3 = s1.CreateRow(3);
+                r3.CreateCell(0).SetCellValue("The");
+                r3.CreateCell(1).SetCellValue("quick");
+                r3.CreateCell(2).SetCellValue("brown");
+                r3.CreateCell(3).SetCellValue("fox");
+                r3.CreateCell(4).SetCellValue("jumps");
+                r3.CreateCell(5).SetCellValue("over");
+                r3.CreateCell(6).SetCellValue("the");
+                r3.CreateCell(7).SetCellValue("lazy");
+                r3.CreateCell(8).SetCellValue("dog");
+                IRow r7 = s1.CreateRow(7);
+                r7.CreateCell(1).CellStyle = pinkStyle;
+                r7.CreateCell(8).CellStyle = blueStyle;
+
+                ClassicAssert.AreEqual(blueStyle.Index, r3.GetCell(4).CellStyle.Index);
+                ClassicAssert.AreEqual(pinkStyle.Index, r3.GetCell(6).CellStyle.Index);
+
+                using (XSSFWorkbook wb2 = XSSFTestDataSamples.WriteOutAndReadBack(wb))
+                {
+                    XSSFSheet wb2Sheet = (XSSFSheet)wb2.GetSheetAt(0);
+                    XSSFRow wb2R3 = (XSSFRow)wb2Sheet.GetRow(3);
+                    ClassicAssert.AreEqual(blueStyle.Index, wb2R3.GetCell(4).CellStyle.Index);
+                    ClassicAssert.AreEqual(pinkStyle.Index, wb2R3.GetCell(6).CellStyle.Index);
+                }
+            }
+        }
     }
 }
diff --git a/testcases/ooxml/XSSF/UserModel/TestXSSFSheet.cs b/testcases/ooxml/XSSF/UserModel/TestXSSFSheet.cs
index 75e1be8cef..84848d943f 100644
--- a/testcases/ooxml/XSSF/UserModel/TestXSSFSheet.cs
+++ b/testcases/ooxml/XSSF/UserModel/TestXSSFSheet.cs
@@ -51,12 +51,6 @@ public TestXSSFSheet()
 
         }
 
-        //[Test]
-        //TODO column styles are not yet supported by XSSF
-        public override void DefaultColumnStyle()
-        {
-            base.DefaultColumnStyle();
-        }
         [Test]
         public void TestTestGetSetMargin()
         {
diff --git a/testcases/ooxml/XSSF/UserModel/TestXSSFWorkbook.cs b/testcases/ooxml/XSSF/UserModel/TestXSSFWorkbook.cs
index 4944e8f913..99c040487f 100644
--- a/testcases/ooxml/XSSF/UserModel/TestXSSFWorkbook.cs
+++ b/testcases/ooxml/XSSF/UserModel/TestXSSFWorkbook.cs
@@ -1347,8 +1347,10 @@ public void LazyStyles_UntouchedStylesPreservedOnSave()
                 savedStylesBytes = IOUtils.ToByteArray(stylesPart.GetInputStream());
             }
 
+            string originalText = Encoding.UTF8.GetString(originalStylesBytes);
+            string savedText = Encoding.UTF8.GetString(savedStylesBytes);
             // The styles.xml must be byte-identical to the original
-            CollectionAssert.AreEqual(originalStylesBytes, savedStylesBytes,
+            CollectionAssert.AreEqual(originalText, savedText,
                 "styles.xml was modified even though styles were never touched");
         }