Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SaveAs by empty IEnumerable<T> without header #133

Closed
shps951023 opened this issue Mar 26, 2021 · 4 comments
Closed

SaveAs by empty IEnumerable<T> without header #133

shps951023 opened this issue Mar 26, 2021 · 4 comments

Comments

@shps951023
Copy link
Member

shps951023 commented Mar 26, 2021

image

@shps951023
Copy link
Member Author

JsonNet

void Main()
{
	{
		object rows = new List<Demo>(){ };
		var json = JsonConvert.SerializeObject(rows);
		Console.WriteLine(json); //[]	
	}
	{
		object rows = new List<Demo>(){ new Demo{}};
		var json = JsonConvert.SerializeObject(rows);
		Console.WriteLine(json); //[{"MyProperty1":null,"MyProperty2":null}]
	}
	{
		object rows = new List<Demo>() { new Demo {Demo2s=new List<Demo2>()} };
		var json = JsonConvert.SerializeObject(rows);
		Console.WriteLine(json); //[{"MyProperty1":null,"MyProperty2":null,"Demo2s":[]}]
	}
	{
		object rows = new List<Demo>() { new Demo { Demo2s = new List<Demo2>() {new Demo2()} } };
		var json = JsonConvert.SerializeObject(rows);
		Console.WriteLine(json); //[{"MyProperty1":null,"MyProperty2":null,"Demo2s":[{"MyProperty1":null,"MyProperty2":null}]}]
	}
}

// You can define other methods, fields, classes and namespaces here
public class Demo
{
	public string MyProperty1 { get; set; }
	public string MyProperty2 { get; set; }
	public List<Demo2> Demo2s { get; set; }
}

public class Demo2
{
	public string MyProperty1 { get; set; }
	public string MyProperty2 { get; set; }
}

@shps951023
Copy link
Member Author

Now default empty Enumerable like jsonnet
If want to have header columns need to specify generic type

MiniExcel.SaveAs<YourType>(parameter);

@shps951023 shps951023 changed the title Empty Enumerable Generic Type Empty Enumerable Type without header Apr 8, 2021
@shps951023 shps951023 reopened this Jun 25, 2021
@shps951023 shps951023 changed the title Empty Enumerable Type without header SaveAs by empty IEnumerable<T> without header Sep 10, 2021
shps951023 added a commit that referenced this issue Sep 10, 2021
@shps951023
Copy link
Member Author

shps951023 commented Sep 10, 2021

image
image
image

@shps951023
Copy link
Member Author

v0.18.0 support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

1 participant