Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions Assets/QuickSheet/Editor/ScriptGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,16 @@ private void WriteMemberField(MemberFieldData field)
var fieldName = GetFieldNameForField(field);
string tmp;
if (field.type == CellType.Enum)
tmp = field.Name + " " + fieldName + ";";
{
if (field.IsArrayType)
{
tmp = field.Name + "[] " + fieldName + ";";
}
else
{
tmp = field.Name + " " + fieldName + ";";
}
}
else
{
if (field.IsArrayType)
Expand All @@ -221,7 +230,16 @@ private void WriteProperty(MemberFieldData field)
var fieldName = GetFieldNameForField(field);

if (field.type == CellType.Enum)
tmp += "public " + field.Name + " " + propertyName + " ";
{
if (field.IsArrayType)
{
tmp += "public " + field.Name + "[]" + " " + propertyName + " ";
}
else
{
tmp += "public " + field.Name + " " + propertyName + " ";
}
}
else
{
if (field.IsArrayType)
Expand Down
15 changes: 15 additions & 0 deletions Assets/QuickSheet/ExcelPlugin/Editor/ExcelQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,21 @@ protected object ConvertFrom(ICell cell, Type t)

if (t.GetElementType() == typeof(string))
return ConvertExt.ToStringArray((string)value);

if (t.GetElementType().IsEnum)
{
var stringValue = cell.StringCellValue.ToString();
var splitValues = stringValue.Split(',');
var enumArray = Array.CreateInstance(t.GetElementType(), splitValues.Length);
for (int i = 0; i < splitValues.Length; ++i)
{
string splitValue = splitValues[i];
var enumValue = Enum.Parse(t.GetElementType(), splitValue, true);
enumArray.SetValue(enumValue, i);
}

return enumArray;
}
}

// for all other types, convert its corresponding type.
Expand Down