Summary
After editing an Excel `.xlsx` file using Telerik RadSpreadsheet and saving it via the default Save option, the saved file becomes corrupted. It no longer opens in RadSpreadsheet (throws an error) and shows a repair warning in Microsoft Excel.
Reproduction Steps
1. Upload an Excel `.xlsx` file to the `ABC` folder on the server.
2. Load the file in RadSpreadsheet via a basic viewer page.
3. Make any small edit (e.g., change a cell’s value).
4. Click the built-in Save option in the RadSpreadsheet toolbar.
5. Attempt to:
- Reopen the saved file in RadSpreadsheet → Error: Object reference not set to an instance of an object.
- Open in Excel → Warning: “We found a problem with some content in ‘filename’. Do you want us to try to recover as much as we can?”
Files Attached
- `Original.xlsx` — Before editing, opens fine in both RadSpreadsheet and Excel.
- `Modified.xlsx` — After saving via RadSpreadsheet, causes errors.
- Screenshot of:
- RadSpreadsheet error :
- Excel repair prompt
Code Snippet :
<telerik:RadSpreadsheet ID="sample" runat="server" Visible="false" style="font-size: 10px;" />
protected void Page_Load(object sender, EventArgs e)
{
string fileName = (string)Session["SelectedFileName"];
SheetLoad(fileName);
}
private void SheetLoad(string fileName)
{
try
{
string filePath = Server.MapPath("~/ABC/" + fileName);
if (!File.Exists(filePath))
{
string errorMsg = "File not found: " + filePath;
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('File not found!');", true);
return;
}
// Load spreadsheet using Telerik document provider
sample.Provider = new SpreadsheetDocumentProvider(filePath);
sample.Visible = true;
}
catch (Exception ex)
{
string errorMsg = "Error opening file: " + ex.Message + " | File: " + fileName;
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Error loading file!');", true);
}
}
**Observation:**
* This only happens for **some files**, especially ones that likely contain advanced Excel features.
* Other simpler files save and reload without any issue.
**Assumption:**
It seems the default save behavior of RadSpreadsheet is **not preserving some Excel structures**, leading to file corruption on save.