Working Excel Program - Transfer To C#

Posted 29 December 2012 - 02:42 PM

Hi All,

I currently have a perfectly working excel program - or coded workbook if you like. But feel that a fully functioning
Software program would be better suited. I am very new to the programming world, and i have started by creating a form with a couple of textboxes for the users input required data and 5 or so buttons to do the do....so to speak.

I have searched many forums - and i can see that it MAY be possible, but im not entirely sure how to go about it.

My Excel Program does the following:
The user - fills in 3 cells (Hoping to replicate with the textboxes on the C# Form)
The user - then presses a button - one for odd or one for even.

No for the hard bit (I Think)

In excel there is an odd sheet and an even sheet both with a lot of concatenation on it from a main page which will also
include the 3 cells the user inputted earlier.

This then produces a script for the user - which is a copy and paste of either the odd or even script.

-------

I suppose im asking - can this be done in C# or can i place the information in the background to work with to produce the usable script.

I dont want it to be done for me - i would like to try and do that myself - just some pointers or snippets of use.

Re: Working Excel Program - Transfer To C#

I wish i could upload a copy of the workbook - but there is far too much sensitive info.

Basically - if the user requires an odd script making. (In Excel)
The 3 cells get filled in by the user and the odd button would be pressed.

In Excel - a hidden ODD sheet would be selected and in column c - there would be the main script.
Within that script there are lots of places where the original 3 cells would be concatenated.
Next - Column c would be copy and pasted (Just Text) into column A on the same ODD sheet
Next - Column a would be copy and pasted onto a scripting sheet for the user to copy and paste from.

This would also be the same for the even.

So could this be done within C# or would it need to manipulate Excel to do this.

'Excel' is then an alias to the Excel Object Model within your module – you could use a different alias. Refer to the following example, which includes "clean up" code, most of which may not be necessary with simple examples.

Re: Working Excel Program - Transfer To C#

This will be a great help i think - it is bed time for me currently, but i will look at it tomorrow.

thanks again

Craig

If the primary purpose of your C# application will be to manipulate Excel then I would question the efficacy of this. There is nothing that C# might do that you couldn't do directly from Excel VBA, and more efficiently.

The only difference is that the C# would run as an independent application. However, if you wanted to, you could create a UserForm in VBA, display it on opening the Excel-file, minimize the Ribbon, etc., so that it (almost) behaves as an application.

The alternative would be to drop the Excel file entirely and program everything in C#; but I assume you still require the Excel file for its other content. Andy.

Re: Working Excel Program - Transfer To C#

Posted 30 December 2012 - 03:01 PM

You have it all in a nutshell there.

I did want to create just an application - which i know i can do excel and have done to an extent.

I would still probably require the excel file - unless there is a way to do it within the C# environment, but being relatively new to programming, probably would find this above my capabilities for my first attempt.

Re: Working Excel Program - Transfer To C#

Posted 30 December 2012 - 03:31 PM

If the data in the spreadsheet were completely static then, if you want to create an entirely independent C# application, you might store this data in a text or XML file within the application; after all, you won't have a spreadsheet to keep the data in.

If I assume that the Excel data is not static, and it needs to be modified at certain points, then the data would need to be stored in a (perhaps shared) database. This makes it a much bigger C# project.

I suggest that you might explore C# completely independently of your Excel work. You would need to start here anyway .

Re: Working Excel Program - Transfer To C#

Posted 31 December 2012 - 07:47 PM

Start out with pencil and paper first.
- What problem are you attempting to solve?
- Design the solution.
- Do you really need to program? Is it non-technical problem? Solvable by training?
- What algorithm are you going to use?
- Code up the solution.