MiniExcel icon indicating copy to clipboard operation
MiniExcel copied to clipboard

SaveAsByTemplate will change template style after exporting

Open shps951023 opened this issue 4 years ago • 0 comments

image

image

void Main()
{
	var manager = new DataTable();
	{
		manager.Columns.Add("GMS_ERRFLAG");
		manager.Columns.Add("GMS_ERRINFO");
		manager.Columns.Add("Pn_Type");
		
		manager.Rows.Add("Pn_Type","GMS_ERRINFO","Pn_Type");
	}
	var value = new Dictionary<string, object>()
	{
		["GMS"] = manager,
	};
	var memoryStream = new MemoryStream();
	memoryStream.SaveAsByTemplate(templatPath, value);
	
	var newFilePath = Path.GetTempPath() + Guid.NewGuid() +  ".xlsx";
	using (var fileStream = File.Create(newFilePath))
	{
		memoryStream.WriteTo(fileStream);
	}
	Console.WriteLine(newFilePath);
}

shps951023 avatar Oct 27 '21 02:10 shps951023