|
|
|
@ -47,36 +47,40 @@ namespace DS.Module.ExcelModule
|
|
|
|
|
for (int n = 0; n < req.ColumnSets.Count; n++)
|
|
|
|
|
{
|
|
|
|
|
var columnSet = req.ColumnSets[n];
|
|
|
|
|
var key = columnSet.DataIndex;
|
|
|
|
|
// var info = new Dictionary<string, object>
|
|
|
|
|
//{
|
|
|
|
|
// { columnSet.Title, temp[key] },
|
|
|
|
|
//};
|
|
|
|
|
var key = columnSet.DataIndex;
|
|
|
|
|
info.Add(columnSet.Title, temp[key]);
|
|
|
|
|
}
|
|
|
|
|
values.Add(info);
|
|
|
|
|
}
|
|
|
|
|
MiniExcel.SaveAs(path, values);
|
|
|
|
|
return DataResult<string>.Success(path);
|
|
|
|
|
//var memoryStream = new MemoryStream();
|
|
|
|
|
//memoryStream.SaveAs(values);
|
|
|
|
|
//memoryStream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
//return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
|
|
|
//{
|
|
|
|
|
// FileDownloadName = filename
|
|
|
|
|
//};
|
|
|
|
|
//using (var memoryStream = new MemoryStream())
|
|
|
|
|
//{
|
|
|
|
|
// memoryStream.SaveAs(values);
|
|
|
|
|
// memoryStream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
// return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
|
|
|
// {
|
|
|
|
|
// FileDownloadName = filename
|
|
|
|
|
// };
|
|
|
|
|
//}
|
|
|
|
|
//MiniExcel.SaveAs(path, values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//throw new NotImplementedException();
|
|
|
|
|
public MemoryStream ExportExcelStreamByColumn(ExportByColumnReq req)
|
|
|
|
|
{
|
|
|
|
|
var filename = Guid.NewGuid() + ".xlsx";
|
|
|
|
|
//var path = Path.Combine(_environment.WebRootPath, "export/" + filename);
|
|
|
|
|
var path = Path.Combine("", "wwwroot/export/" + filename);
|
|
|
|
|
var data = JArray.Parse(req.JsonDataStr);
|
|
|
|
|
|
|
|
|
|
var values = new List<Dictionary<string, object>>();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < data.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var temp = data[i];
|
|
|
|
|
var info = new Dictionary<string, object>();
|
|
|
|
|
for (int n = 0; n < req.ColumnSets.Count; n++)
|
|
|
|
|
{
|
|
|
|
|
var columnSet = req.ColumnSets[n];
|
|
|
|
|
var key = columnSet.DataIndex;
|
|
|
|
|
info.Add(columnSet.Title, temp[key]);
|
|
|
|
|
}
|
|
|
|
|
values.Add(info);
|
|
|
|
|
}
|
|
|
|
|
var memoryStream = new MemoryStream();
|
|
|
|
|
memoryStream.SaveAs(values);
|
|
|
|
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
return memoryStream;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|