Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ParseDescriptionFormula(RowInfo r, string columnId, StringBuilder descFormat, Dictionary<string, AbilityTKArgument> partTKArgs)
- {
- var formula = r.GetFormula(columnId);
- if (string.IsNullOrEmpty(formula))
- {
- descFormat.Append(r.GetTrimmedString(columnId));
- return;
- }
- var formulaParts = formula.Split('&');
- for (var i = 0; i < formulaParts.Length; i += 1)
- {
- var formulaPart = formulaParts[i].Trim();
- if (formulaPart.StartsWith("\""))
- {
- var text = formulaPart.Trim('\"');
- if (text.StartsWith("(X)"))
- {
- text = text.Substring(3);
- PrintUniqueWarn("Removed (X) from description, it's deprecated, row: " + r.Row);
- }
- descFormat.Append(text);
- continue;
- }
- object value;
- string format;
- var match = TextFuncRegex.Match(formulaPart);
- if (match.Success)
- {
- var groups = match.Groups.Cast<Group>().ToArray();
- value = Worksheet.Calculate(groups[1].Value);
- format = (string)Worksheet.Calculate(groups[2].Value);
- }
- else
- {
- value = Worksheet.Calculate(formulaPart);
- format = "0";
- }
- if (value is double)
- {
- value = (float)(double)value;
- }
- descFormat.Append("{" + partTKArgs.Count + "}");
- var arg = new AbilityTKArgument() { Format = format, IsConst = true };
- if (value is float)
- {
- arg.FloatValue = (float)value;
- }
- else if (value is string)
- {
- arg.StringValue = (string)value;
- }
- else
- {
- PrintUniqueError("Unsupported arg type: " + value.GetType() + " in row " + r.Row);
- }
- foreach (Match cell in CellRefRegex.Matches(formulaPart))
- {
- var addr = new ExcelAddress(cell.Value);
- if (IsColumnAffectedByMastery(addr.Start.Column))
- {
- arg.IsConst = false;
- }
- }
- partTKArgs.Add(format, arg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement