You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Goal - fill columns created dynamically. I can not use class with pre-created fields because in my case tags have to be found first.
Expectations:
excel:
{{model.name}} {{manufacturer.name}}
after processing:
A1 B1
A2 B2
A3 B3
A4 B4
Reality:
code:
var value = new Dictionary<string, object>
{
["model"] = new[]
{
new { name = "A1" },
new { name = "A2" },
new { name = "A3" },
new { name = "A4" }
},
["manufacturer"] = new[]
{
new { name = "B1" },
new { name = "B2" },
new { name = "B3" },
new { name = "B4" },
},
};
excel:
{{model.name}} {{manufacturer.name}}
Result
B1 {{manufacturer.name}}
B2 {{manufacturer.name}}
B3 {{manufacturer.name}}
B4 {{manufacturer.name}}
Another approach through multiple SaveAsByTemplateAsync()
code:
MemoryStream memoryStream = new MemoryStream(0);
memoryStream.Write(bytes, 0, bytes.Length);
var value = new Dictionary<string, object>
{
["model"] = new[]
{
new { name = "A1" },
new { name = "A2" },
new { name = "A3" },
new { name = "A4" }
},
};
byte[] copiedData = memoryStream.ToArray();
await memoryStream.SaveAsByTemplateAsync(copiedData, value);
memoryStream.Position = 0;
MemoryStream clonedStream = new MemoryStream();
await memoryStream.CopyToAsync(clonedStream);
clonedStream.Position = 0;
await memoryStream.DisposeAsync();
byte[] copiedData1 = clonedStream.ToArray();
var value1 = new Dictionary<string, object>
{
["manufacturer"] = new[]
{
new { name = "B1" },
new { name = "B2" },
new { name = "B3" },
new { name = "B4" }
},
};
await clonedStream.SaveAsByTemplateAsync(copiedData1, value1);
Goal - fill columns created dynamically. I can not use class with pre-created fields because in my case tags have to be found first.
Expectations:
excel:
{{model.name}} {{manufacturer.name}}
after processing:
A1 B1
A2 B2
A3 B3
A4 B4
Reality:
code:
excel:
{{model.name}} {{manufacturer.name}}
Result
B1 {{manufacturer.name}}
B2 {{manufacturer.name}}
B3 {{manufacturer.name}}
B4 {{manufacturer.name}}
Another approach through multiple SaveAsByTemplateAsync()
code:
Result
A1 B1
A1 B2
A1 B3
A1 B4
A2 B1
A2 B2
A2 B3
A2 B4
A3 B1
A3 B2
A3 B3
A3 B4
A4 B1
A4 B2
A4 B3
A4 B4
The text was updated successfully, but these errors were encountered: