Invalid data before reference sign '!': L|0-4|(L|5-8|)

Hello,
I have updated our aspose version to 18.6.1.
I am facing some issue with setting chart series. I am getting error like “Invalid data before reference sign ‘!’: L|0-4|(L|5-8|)”.

I am adding worksheet dynamically name “Data(MV)”.
Workbook wb = new Workbook(new MemoryStream(Properties.Resources.AP_RelativeCharts));
wb.Worksheets.Clear();
wb.Worksheets.Add(“Chart(MV)”);
Worksheet worksheetchartmv = wb.Worksheets[0];
wb.Worksheets.Add(“Chart(Dur)”);
Worksheet worksheetDur = wb.Worksheets[1];
wb.Worksheets.Add(“Data(Dur)”);
Worksheet worksheetDataDur = wb.Worksheets[2];
worksheetDataDur.IsVisible = false;
wb.Worksheets.Add(“Data(MV)”);
Worksheet worksheetDataMV = wb.Worksheets[3];
worksheetDataMV.IsVisible = false;

The error it throws to me when I add series to chart.
String sheetName = “Data(Dur)”;
string alphaCode = “B”;
string seriesrange = string.Concat(sheetName, “!$”, alphaCode, “$2:$”, alphaCode, “$”, MaxDataRow + 1);
chart.NSeries.Add(seriesrange, true); //I get error here

I am able to resolve error by removing bracket from my worksheet name and making it “Data_MV”.
But what is the real issue behind this I am not able to understand. Please suggest me the proper solution for this.

Thanks,
Sarthak

@spathak,

Thanks for the code segment and details.

Could you also provide your template Excel file with sample code (runnable) to reproduce the issue, we will check it soon. You may also create a sample console demo application (runnable), zip the project and post us here to show the issue.

I got the solution. I have used the escape " ’ "(single quote) character.
For example.

chart.Nseries.Add(" ’ Data(MC) ’ ! A1:B45");

@spathak,

Good to know that you have sorted out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.