Question

Is there any way for my app to create a document that will need saved and printed without utilizing some external software? Currently I have a spreadsheet that does a bunch of calculations then a button that runs some VBA to export 2 sheets to a PDF, then it saves and prints it. I want to port this spreadsheet into a .NET app.

I have experience with everything EXCEPT this: how do I re-create these 2 documents that are currently in Excel, without having to utilize Excel? My whole goal here is to get out of Excel...because I hate it, and I'd like to send this app to clients across the country. I really don't want to have to tell clients that they need Excel to use this. I might as well just leave it in the spreadsheet if that's the case.

I'm sorry if this is sort of "nooby", but I'm not sure what the best course of action here is. Should I try to mimic my Excel sheets on 2 hidden forms and save/print those? Should I write some HTML to produce these forms in a browser and save/print from there? Are there any other options here? I'll probably end up saving as XPS if I can find a way to get out of Excel. Would love some pointers if you have any ideas. Thanks everyone!

Edit: a little more info...I don't need help with the calculations, or exporting PDF's. I don't need any help regarding Excel or VBA. The workbook has 1 input sheet where users enter data. The results of the calculations appear on 2 other sheets in this workbook. These 2 sheets are currently exported to 1 PDF using VBA, which is then saved and printed using VBA. These spreadsheets are not "spreadsheets" like you may be thinking. They are actually "forms", for lack of a better term, that the user will never edit after running the macro to export them as PDF's. They contain text, pictures, shapes, etc. Excel is merely the medium currently being used to create these documents. My goal is to build this project in .NET and get us out of Excel, but I'm not quite sure how to reproduce these 2 forms within my app without utilizing Office. Think of them as templates. After the user enters data in my app, it will do some calculations, and the results need to appear on 2 forms that need printed and saved on the user's machine. How do I recreate these 2 forms in .NET?

Of ya, vb.net, winforms (although I could use WPF as I haven't started yet), 4.0 framework :)

Was it helpful?

Solution

Here is what you can do:

  1. Add an empty Excel file into your resources and use it as template

  2. When your program is to save data, you can take that file from resources and save it to hard disk.

  3. Connect to Excel file using "Microsoft.Ace.oleDb."

  4. Save and read data in Excel just as it was a db table - there are plenty examples on the net. Google for it.

For this project you don't need Excel application on the machine.

Now, if your concern is Excel, you don't have to worry. Your clients can use OpenOffice, for example. Or, you can save data in CSV format. CSV is not Excel. You can create your own text format and your clients will be able to read it with the Notepad. You can do HTML/XML combination and have your html page load whatever xml you supply.

Seriously, create a spreadsheet and tell your clients that they can open it with their favorite spreadsheet editor.

OTHER TIPS

So instead of using a third party program or anything fancy , you could just read in the excel or xsl file and spit it out? Just write some code to format the data properly for users... There is a similar question that may help you with a tutorial - Here But this is for java, Are you using c# or vb ? .Net 4.5 ? razor ?

You can create the PDF's from code using tools like iTextSharp. Or use fillable PDF templates and use iTextsharp to fill in the form. You will need a program to print the PDF, I use the Foxit Reader. I'm sure there are some full featured PDF tools out there that include printing.

You can also doing printing from VB.Net but I would guess mixed media documents would be difficult.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top