Hello,
1. issue:
ExcelVmlDrawingBase.SetStyle function trims last character of the style xml. This is aimed to delete the trailing semicolon. But if there were no semicolon at the end (if the changed key:value pair was in the middle), it trims the last character making the last key:value pair not valid.
2. issue:
If the style XML was empty before the function call, it gets a leading semicolon like ";key:value"
Please replace the line (now it is line 159)
```
newStyle = style.Substring(0, style.Length - 1);
```
with the following:
```
newStyle = style;
```
and the last line
```
return newStyle;
```
with this one, which removes both trailing and leading semicolons:
```
return newStyle.Trim(new[] { ';' });
```
Here is how the whole function looks by me now:
```
protected string SetStyle(string style, string key, string value)
{
string[] styles = style.Split(';');
string newStyle="";
bool changed = false;
foreach (string s in styles)
{
string[] split = s.Split(':');
if (split[0].Trim() == key)
{
if (value.Trim() != "") //If blank remove the item
{
newStyle += key + ':' + value;
}
changed = true;
}
else
{
newStyle += s;
}
newStyle += ';';
}
if (!changed)
{
newStyle += key + ':' + value;
}
else
{
newStyle = style;
}
return newStyle.Trim(new[] { ';' });
}
```
Comments: Sorry if this wasn't clear. My question was directed at the original developers. Your issue makes sense.
1. issue:
ExcelVmlDrawingBase.SetStyle function trims last character of the style xml. This is aimed to delete the trailing semicolon. But if there were no semicolon at the end (if the changed key:value pair was in the middle), it trims the last character making the last key:value pair not valid.
2. issue:
If the style XML was empty before the function call, it gets a leading semicolon like ";key:value"
Please replace the line (now it is line 159)
```
newStyle = style.Substring(0, style.Length - 1);
```
with the following:
```
newStyle = style;
```
and the last line
```
return newStyle;
```
with this one, which removes both trailing and leading semicolons:
```
return newStyle.Trim(new[] { ';' });
```
Here is how the whole function looks by me now:
```
protected string SetStyle(string style, string key, string value)
{
string[] styles = style.Split(';');
string newStyle="";
bool changed = false;
foreach (string s in styles)
{
string[] split = s.Split(':');
if (split[0].Trim() == key)
{
if (value.Trim() != "") //If blank remove the item
{
newStyle += key + ':' + value;
}
changed = true;
}
else
{
newStyle += s;
}
newStyle += ';';
}
if (!changed)
{
newStyle += key + ':' + value;
}
else
{
newStyle = style;
}
return newStyle.Trim(new[] { ';' });
}
```
Comments: Sorry if this wasn't clear. My question was directed at the original developers. Your issue makes sense.