Invalid data before reference sign '!':


Hello ,
I am getting Invalid data before reference sign ‘!’: L|18-21|%(Based on cell Total Summary!A7) error while capturing screen shot using aspose of the sheet.
i tried to delete the content from the sheet too… but still throws some error.
image.png (38.9 KB) (194.7 KB)
Please find the xls in attachment.



Thanks for the template file and screenshot.

Could you also provide sample code (runnable) to show the issue, we will check it soon.


public async Task MergeToDoc(SeymourContext spContext,
string tempFile)
DateTime now = DateTime.Now;

            //Download Template File from SharePoint
            //  tempFile = TemplatePath + "/test.xls";
            var templateFileXls = new FileStream(tempFile, FileMode.Open);
            var templateFileDoc = new FileStream(TemplatePath + "/" + MERGEDOCTEMPLATE, FileMode.Open);
            var afterTemplateFile = (DateTime.Now - now).TotalMilliseconds;
            //Create Aspose Document
            var doc = new Document(templateFileDoc);
            Workbook workbook = new Workbook(templateFileXls);
            //Get the first worksheet in the book.
            Worksheet worksheet = workbook.Worksheets[0]; //**Code breaks here**
            doc.CompatibilityOptions.UseWord2010TableStyleRules = true;
            var afterMergeCommon = (DateTime.Now - now).TotalMilliseconds;
            var customPlaceholders = new SffPlaceholderModel();
            //read from sheet and store
            customPlaceholders.BodyCorporate = worksheet.TextBoxes.Where(a => a.Name == "BodyCorporate").Select(b => b.Text).Single().ToString();

            customPlaceholders.ContingencyAllowance = worksheet.TextBoxes.Where(a => a.Name == "ContingencyAllowance").Select(b => b.Text).Single().ToString();
            customPlaceholders.BuildingType = worksheet.Cells["F47"].Value.ToString();
            customPlaceholders.RegisteredForGST = worksheet.Cells["F71"].Value.ToString();
            customPlaceholders.ForecastPeriod = worksheet.Cells["F73"].Value.ToString();
            customPlaceholders.InspectionDate = worksheet.TextBoxes.Where(a => a.Name == "InspectionDate").Select(b => b.Text).Single().ToString();
            customPlaceholders.WorkerId = Convert.ToInt32(worksheet.TextBoxes.Where(a => a.Name == "WorkOrder").Select(b => b.Text).Single().ToString());
            doc = await base.MergeCommon(customPlaceholders, doc, null);
            var docBuilder = new DocumentBuilder(doc);
            //Add screenshots for other sheets  using on bookmarks
            GenerateImage(docBuilder, workbook, 0);
            GenerateImage(docBuilder, workbook, 1);
            GenerateImage(docBuilder, workbook, 2);

            //Add Page Number
            var afterMerge = (DateTime.Now - now).TotalMilliseconds;
            var fileName = string.Format("Sff-{0}-{1}.docx", customPlaceholders.PropertyName, customPlaceholders.WorkerId);
            //Return Docx Merged BYTES
            using (var ms = new MemoryStream())
                Aspose.Words.Saving.OoxmlSaveOptions saveOptions = new Aspose.Words.Saving.OoxmlSaveOptions(Aspose.Words.SaveFormat.Docx);
                saveOptions.Compliance = Aspose.Words.Saving.OoxmlCompliance.Iso29500_2008_Strict;
                doc.Save(ms, saveOptions);
                FileModel fileModel = new FileModel(fileName, ms.ToArray());
                var afterDocSave = (DateTime.Now - now).TotalMilliseconds;
                return fileModel;

        catch (Exception ex)
            //TO DO, add loggging




Thanks for the sample code.

After an initial test, I am able to observe the issue as you mentioned by loading your template file via Aspose.Cells APIs. I found an exception “Invalid data before reference sign ‘!’: L|18-21|%(Based on cell Total Summary!A7)” when loading the file:
Sample code:

Workbook workbook = new Workbook("e:\\test2\\test.xlsx");

I have logged a ticket with an id “CELLSNET-46212” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.


Thank you @Amjad_Sahi .
We are waiting for the response from Aspose as we have to deliver the project soon.
Hope we would get it soon.



This is to inform you that we have fixed your issue “CELLSNET-46212” now. We will soon provide you the fixed version in the next few days (3-5) after performing QA and incorporating other enhancements and fixes.



Thanks for using Aspose APIs.

Please download and try the following fix and let us know your feedback.


Thanks @shakeel.faiz .
This is working for me now.



You are welcome.


The issues you have found earlier (filed as CELLSNET-46212) have been fixed in Aspose.Cells for .NET v18.7. Please also check the document/article for your reference: