title: OpenXML Custom column width not working
body: <p>I'm trying to change the width of some excel columns. I've tried everything but I keep getting empty excel documents, my excel file works fine without this addition:</p>
  
  <pre><code>Columns columns = new Columns();
  
  columns.Append(new Column() { Min = 1, Max = 3, Width = 20, CustomWidth = true });
  columns.Append(new Column() { Min = 4, Max = 4, Width = 30, CustomWidth = true });
  
  wsPart.Worksheet.Append(columns);
  </code></pre>
  
  <p>But as soon as I add this <a href="https://stackoverflow.com/a/38150078/6953120">like this user suggested</a>, I have to repair my excel file, and it will be empty. I get this error: "Replaced Part: /xl/worksheets/sheet.xml part with XML error.  Load error. Line 1, column 0.
  ". And the 'repaired' file is empty.</p>
  
  <p>My code is basically the same as that from the <a href="https://msdn.microsoft.com/en-us/library/office/cc861607.aspx" rel="nofollow noreferrer">MSDN example</a></p>
  
  <p>I've tried many different ways of changing the column width, so I think the problem lies elsewhere. I can't seem to figure out what's wrong.</p>
  
  <p>EDIT: Full code</p>
  
  <pre><code>_document = SpreadsheetDocument.Create(newFileName, SpreadsheetDocumentType.Workbook);
  
  _workbookPart = _document.AddWorkbookPart();
  _workbookPart.Workbook = new Workbook();
  
  WorksheetPart worksheetPart = _workbookPart.AddNewPart&lt;WorksheetPart&gt;();
  worksheetPart.Worksheet = new Worksheet(new SheetViews(new SheetView { WorkbookViewId = 0, ShowGridLines = new BooleanValue(false) }), new SheetData());
  
  _document.WorkbookPart.Workbook.AppendChild(new Sheets());
  
  Sheet sheet = new Sheet { Id = _document.WorkbookPart.GetIdOfPart(worksheetPart), SheetId = 1, Name = "Sheet1" };
  _workbookPart.Workbook.Sheets.Append(sheet);
  
  
  WorkbookStylesPart stylesPart = _workbookPart.AddNewPart&lt;WorkbookStylesPart&gt;();
  stylesPart.Stylesheet = CreateStylesheet();
  stylesPart.Stylesheet.Save();
  
  Columns columns = new Columns();
  
  columns.Append(new Column() { Min = 1, Max = 3, Width = 20, CustomWidth = true });
  columns.Append(new Column() { Min = 4, Max = 4, Width = 30, CustomWidth = true });
  
  worksheetPart.Worksheet.Append(columns);
  
  _sheetData = worksheetPart.Worksheet.GetFirstChild&lt;SheetData&gt;();
  </code></pre>