Reputation: 1001
I'm looking to generate some C# code based on Excel data. Basically the Excel sheet contains definitions of functions that need to be generated in C#.
My current experience with code generation is mainly with ORM's. But now the "input" is Excel data.
I'm asking this to prevent me from re-inventing the wheel. Reading data from Excel is easy, and generating C# also. But I'm a lazy programmer.
Is there a code generation tool that accepts Excel files as input?
Upvotes: 3
Views: 2769
Reputation: 41
You may use DestallMaterials.CodeGeneration package. It uses Blazor templates (and c# code) to generate source code files. You may parse your excel and the feed it to a template, that will give you the code.
Upvotes: 0
Reputation: 4493
Having worked with this problem before, I suggest that you convert the excel file to a CSV. Im my case, I transformed the CSV file into C# classes (which include property and method definitions).
Upvotes: 1
Reputation: 1620
I am guessing you will have to hand roll this solution. This does seem a little wonky, would be curious how you got in a situation where you are needing to do code gen based on Excel?!?
Upvotes: 2
Reputation: 11079
You can use T4 templates. I know this too common/abstract answer, but this is the way, I think, and I don't think you can find something already exist for that purpose. Visual Studio 2008 has native supports for them. In your T4 template you can read excel file and then use its data to create any code file you want.
Upvotes: 3