Hi,
I’ve been using Aspose to edit some Excel spreedsheets, but users are reporting a peculiar issue that I can’t seem to get to the bottom of. Once the file has been edited by the program, a user opens the file up and then, without making any changes at all, closes it, rather than simply closing, the save changes dialog box pops up asking the user if they want to discard their changes.
If they do the same before the file has been processed by Aspose, this doesn’t happen. It’s not a major issue, but it is causing some annoyance/confusion with users. I have put together some test code and attached a sample file that replicates the issue.
class Program
{
static void Main(string[] args)
{
if (File.Exists(@“C:\temp\promptTest1.xlsx”))
File.Delete(@“C:\temp\promptTest1.xlsx”);
var lic = new License();
lic.SetLicense(“Aspose.Total.lic”);
var template = @“C:\sandbox\ExcelSavePrompt\ExcelSavePrompt\App_Data\Test1.xlsx”;
Workbook wb = new Workbook(template);
foreach (Worksheet sh in wb.Worksheets)
{
if (sh.Name.Equals(“Aspose Test”, StringComparison.InvariantCultureIgnoreCase))
wb.Worksheets.RemoveAt(“Aspose Test”);
var textboxes = sh.TextBoxes;
for (var index = 0; index < sh.TextBoxes.Count; index++)
{
if (textboxes[index].Name.Contains(“Aspose_Test_Banner”))
{
textboxes.RemoveAt(index);
index–;
}
}
}
Worksheet classifiedSheet = wb.Worksheets[wb.Worksheets.Add()];
classifiedSheet.Name = “Aspose Test”;
Worksheet sheet = wb.Worksheets[“Aspose Test”];
int textboxIndex = sheet.TextBoxes.Add(0, 0, 20, 1000);
TextBox banner = sheet.TextBoxes[textboxIndex];
banner.Text = “TEST BANNER”;
banner.Name = “Aspose_Test_Banner” + Guid.NewGuid().ToString();
banner.Placement = PlacementType.FreeFloating;
banner.Font.Color = Color.White;
banner.Font.Size = 10;
banner.TextHorizontalAlignment = TextAlignmentType.Center;
banner.TextVerticalAlignment = TextAlignmentType.Center;
MsoFillFormat fillFormat = banner.FillFormat;
fillFormat.ForeColor = Color.Red;
MsoLineFormat lineFormat = banner.LineFormat;
lineFormat.Style = MsoLineStyle.Single;
lineFormat.Weight = 0;
banner.ZOrderPosition = 1;
wb.Save(@“C:\temp\Output.xlsx”);
}
}
If someone could shed some light on what’s happening it would be much appreciated!
Many thanks!