Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Commented Issue: "Unreadable content" when editing and reopening generated file in Excel 2010 [8466]

$
0
0
The problem is described in the discussions in the following thread: http://closedxml.codeplex.com/discussions/403797
When I open an existing Excel file using ClosedXml and save it (even without performing any actions), the file gets corrupted when it is edited using Excel 2010 afterwards. Excel 2007 and Excel 2013 do not produce the problem on my Systems (tested with WinXP and Win8).
I've attached the following small sample program:

```
namespace ClosedXml_Template_Test
{
using System.IO;
using ClosedXML.Excel;
class Program
{
static void Main(string[] args)
{
string inFilepath = "Template.xlsx";
string outFilepath = "Generated.xlsx";
byte[] fileContent;
using (FileStream fileStream = File.OpenRead(inFilepath))
{
// Read from file
fileContent = new byte[fileStream.Length];
fileStream.Read(fileContent, 0, fileContent.Length);
}
using (MemoryStream memStream = new MemoryStream())
{
// Write to MemoryStream
memStream.Write(fileContent, 0, fileContent.Length);
// Create ClosedXml instances
using (XLWorkbook workbook = new XLWorkbook(memStream, XLEventTracking.Disabled))
{
// Save the workbook to the stream
workbook.Save();
}
// Get the content from the stream
fileContent = memStream.ToArray();
}
if (File.Exists(outFilepath))
{
// Delete existing generated file
File.Delete(outFilepath);
}
using (FileStream fileStream = File.OpenWrite(outFilepath))
{
// Save the new file
fileStream.Write(fileContent, 0, fileContent.Length);
}
}
}
}
```

EDIT: Reformatted the post (CodePlex somehow killed the layout...)
Comments: I would like to look into this, but I am unable to reproduce the issue on my machine. Can you tell me what versions off Excel/Office you are using, and if the issue still happens for you.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>