I'm looking for the best way to achieve the following workflow.
Ask a series of questions
Captured the responses
Use the answers captured to either hide or show certain aspects of word document.
Save the complete word document to a location (TBD).
I'm not a developer, so will need to source one who could pick this up, but before I do I wanted to know the best approach to this workflow.
Appreciate any feedback you can offer.
Cheers
There are several libraries for interacting with Word (.docx) documents in C#, such as NPOI and DocX, and it is not theoretically complicated to programatically populate a document based on user input and some decision tree and then save it somewhere locally or expose it for download via a web interface. But, keep in mind, that's only part of the solution -- apps have to be hosted, secured, monitored, etc., and that's where the "hard" part is likely to be.
If you are looking to accomplish this within an enterprise environment that uses Microsoft Office 365, you may not need a developer at all. Microsoft Flow / Microsoft PowerAutomate allows you to produce complex workflows such as the one you described. There's a very similar one listed here:
https://flow.microsoft.com/en-us/galleries/public/templates/3c651e28cded46aab2ba40a2c3116f30/create-word-and-pdf-documents-from-microsoft-forms/
My question seems confusing but I'll let you explain it more clearly. Me and my team we're currently developing a complex report that comprises of words, tables and charts. As of now we generate this report by using a word document template and filling it up with the model we have. As for chart this is where it becomes complicated, we have two application that we're using in business one is a windows/wpf application and a web application. Both application uses the same engine we have for generating chart (ComponentOne) but the engine itself is only compatible for windows application. We use the assembly we generate from windows/wpf application on our web application for us to generate a report.
Our report generator on website will only have filter and parameters on what kind of report they want to generate and on a press of button. What do you think will be the best to tackle this issue so that we can drop using the assembly we have. We don't like to drop using template for this as these greatly help us on maintaining the report when changes is required the only thing that we think right now on how can we generate a chart on memory and convert it into an image so that we can dump it on our template.
It's not confusing, it's just not clear at all. If I get it right you just have a reporting tools ComponentOne that make reports on software side and it's not adapated for web side.
You somewhat tried to tackle it by using software dll in your website and it doesn't work as well as you expected/wanted. And you keep trying as of now.
Your question is basicly "How can I use a dll designed for software into a website?"
And the answer is simple. It's case by case when not outright impossible.
I invite you to look for another solution than using a software designed dll on a website. Even your idea of putting it inside an image is somewhat bad (lose of all controllers / defeat of the purpose of an interactive report.)
I'm pretty sure that ComponentOne would have think of such a problem as web reports and maybe even a solution to link web reports to soft reports. With a little search, I found a C1WebReport and even found some forums talking about C1Report to C1WebReport. Does it answer your problem?
This question might be more subjective, but I'm hoping someone with more experience can guide me in the right direction.
I'm brand new to web development, but have been coding C# for a couple years. My job wants me to convert an existing app we have to SharePoint 2013 and part of the app generates an excel report with custom formats and styling. In the original app we used Interop, but apparently since it's 32bit and our server is 64bit, Interop won't work. I thought about just doing a csv, but our customer is adamant about keeping the styling so I found OpenXML.
I don't have any experience with OpenXML, but I saw the tool can convert files into code. I loaded our template into the tool and it generated about 2000 lines of code which seems very excessive. Using Interop it's a fraction of the length and seems much easier to read. I'm tempted to just copy all the code over and stick it in a region (which I know most developers hate and I agree looks bad) and put a note at the top saying that if the template ever changes to just redo that region with the new one.
Is that my best option or is there a better alternative? Unfortunately our dev network is pretty closed off (it's a pain to get approval on third party non Microsoft stuff) so I'm limited on third party libraries I can add as well. If there's an option without doing that, that'd be preferred.
If you have one or more templates, just use OpenXML to create a new workbook from a template for each request. And then use code to enter values into named ranges, datasets into rows, etc.
BTW—ClosedXML makes simple and medium things a lot easier.
Ok, so I'm building a kind of reporting central for the company I work at and the easy part was building a web based file browser, now I'm moving on to the report aspect of it and to start it off, I'm integrating Crystal Reports.
I've already gotten the files from the SAP website for them, but I'm encountering a couple problems,
First off, all the examples I've found make it so that you have to define the data source/database, and include log in information for it in the code. This is a problem because we have a LOT of crystal reports, with a lot of different database references, so I can't just use one for all of them. In fact, there are reports that we use that reference multiple database at the same time.
Secondly, all the examples I've found make it seem like you have to have a specific page created for each report. My goal is to be able to have the report link as a variable and have one page for all of the reports we have.
I looked at everything I could find yesterday and I couldn't find what I needed. I'm also wondering what on earth the ReportClass.Load function even does. It was in every example I could find and I didn't notice any explicit difference in the ReportClass I had when I used it.
While searching, I found an answer that suggested building a web forms application that would build the Reports, and then use an I-Frame to grab it, but that's something I want to avoid.
So in review:
1) I need to build Crystal Reports without having to reference the Database
2) I need it to be flexible to a variable Report by supplying just the path to the .rpt file
3) I would like it to be in a single application, in MVC, and avoiding IFrames
Thank you so much for your help!!
EDIT: I found a solution that works for me. Instead of using a RAZOR view, I used an ASPX view, which has the Crystal Reports Viewer Tool in the toolbox. In order to make it variable I used the ViewBag.
Controller Code:
[HttpGet]
public ActionResult Viewer(string Path)
{
var sessionID = Session.SessionID;
ViewBag.Path = newPath;
return View();
}
ASPX View Code:
<% Report.Report.FileName = ViewBag.Path; %>
<CR:CrystalReportViewer ID="Viewer" runat="server" AutoDataBind="True" GroupTreeImagesFolderUrl="" Height="100%" ReportSourceID="Report" ToolPanelWidth="200px" Width="100%" />
<CR:CrystalReportSource ID="Report" runat="server">
<Report></Report>
</CR:CrystalReportSource>
A "similar" (not exact) question was asked here. Hopefully that can get you down the right path.
1) I need to build Crystal Reports without having to reference the Database
Have you considered building a data warehouse for your reporting and analysis needs? A data warehouse has many benefits over a traditional reporting structure especially when drawing data from multiple sources.
In regards to point 2 & 3 have you considered that crystal reports may simply not be the most ideal reporting solution?
Crystal reports is a powerful tool but honestly I'm not a big fan of it when it comes providing reporting intelligence over the internet or an intranet.
Having you considered switching tools? For example http://www.tableausoftware.com/ provides some excellent data visualization tools and IMO is a much better tool for the job you are describing.
Note, that this is simply one tool (as there are many out there), but one that I have had some experience with and it exceeded our expectations especially when sitting on top of a data warehouse.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am working on a project right now that involves receiving a message from another application, formatting the contents of that message, and sending it to a printer. The technology of choice is C# windows service. The output could be called a report, I suppose, but a reporting engine is not necessary. A simple templating engine, like StringTemplate, or even XSLT outputting HTML would be fine. The problem I'm having is finding a free way to print this kind of output from a service. Since it seems that it will work, I'm working on a prototype using Microsoft's RDLC, populating a local report and then rendering it as an image to a memory stream, which I will then print. Issues with that are:
Multi-page printing will be a big headache.
Still have to use PrintDocument to print the memory stream, which is unsupported in a Windows Service (though it may work - haven't gotten that far with the prototype yet)
If the data coming across changes, I have to change the dataset and the class that the data is being deserialized into. bad bad bad.
Has anyone had to do anything remotely like this? Any advice? I already posted a question about printing HTML without user input, and after wasting about 3 days on that, I have come to the conclusion that it cannot be done, at least not with any freely available tool.
All help is appreciated.
EDIT: We are on version 2.0 of the .NET framework.
Trust me, you will spend more money trying to search/develop a solution for this as compared to buying a third party component. Do not reinvent the wheel and go for the paid solution.
Printing is a complex problem and I would love to see the day when better framework support is added for this.
Printing from a Windows service is really painful. It seems to work... sometimes... but finally it craches or throws an exception from time to time, without any clear reason. It's really hopeless. Officially, it's even not supported, without any explanation, nor any proposal for an alternate solution.
Recently, I have been confronted to the problem and after several unsuccessful trials and experimentations, I came finally with two viable solutions:
Write your own printing DLL using the Win32 API (in C/C++ for instance), then use it from your service with P/Invoke (works fine)
Write your own printing COM+ component, then uses it from your service. I have chosen this solution with success recently (but it was third party COM+ component, not own written) It works absolutely fine too.
I've done it. It's a pain in the A*s. The problem is that printing requires that GDI engine to be in place, which normally means that you have to have the desktop, which only loads when you're logged in. If you're attempting to do this from a Service on a Server, then you normally aren't logged in.
So first you can't run as the normal service user, but instead as a real user that has interactive login rights. Then you have to tweak the service registry entries (I forget how at the moment, would have to find the code which I can do tonight if you're really interested). Finally, you have to pray.
Your biggest long term headache will be with print drivers. If you are running as a service without a logged in user, some print drivers like to pop up dialogs from time to time. What happens when your printer is out of toner? Or out of paper? The driver may pop up a dialog that will never be seen, and hold up the printer queue because nobody is logged in!
To answer your first question, this can be fairly straight forward depending on the data. We have a variety of Service-based applications that do exactly what you are asking. Typically, we parse the incoming file and wrap our own Postscript or PCL around it. If you layout is fairly simple, then there are some very basic PCL codes you can wrap it with to provide the font/print layup you want (I'd be more then happy to give you some guidance here offline).
One you have a print ready file you can send it to a UNC printer that is shared, directly to a locally installed printer, or even to the IP of the device (RAW or LPR type data).
If, however, you are going down the PDF path, the simplest method is to send the PDF output to a printer that supports direct PDF printing (many do now). In this case you just send the PDF to the device and away it prints.
The other option is to launch Ghostscript which should be free for your needs (check the licensing as they have a few different version, some GNU, some GPL etc.) and either use it's built in print function or simply convert to Postscript and send to the device. I've used Ghostscript many times in Service apps but not a huge fan as you will basically be shelling out and executing a command line app to do the conversion. That being said, it's a stable app that does tend to fail gracefully
Printing from a service is a bad idea. Network printers are connected "per-user". You can mark the service to be run as a particular user, but I'd consider that a bad security practice. You might be able to connect to a local printer, but I'd still hesitate before going this route.
The best option is to have the service store the data and have a user-launched application do the printing by asking the service for the data. Or a common location that the data is stored, like a database.
If you need to have the data printed as regular intervals, setup a Task event thru the Task Scheduler. Launching a process from a service will require knowing the user name and password, which again is bad security practice.
As for the printing itself, use a third-party tool to generate the report will be the easiest.
This may not be what you're looking for, but if I needed to do this quick&dirty, I would:
Create a separate WPF application (so I could use the built-in document handling)
Give the service the ability to interact with the desktop (note that you don't actually have to show anything on the desktop, or be logged in for this to work)
Have the service run the application, and give it the data to print.
You could probably also jigger this to print from a web browser that you run from the service (though I'd recommend building your own shell IE, rather than using a full browser).
For a more detailed (also free) solution, your best bet is probably to manually format the document yourself (using GDI+ to do the layout for you). This is tedious, error prone, time consuming, and wastes a lot of paper during development, but also gives you the most control over what's going to the printer.
If you can output to post script some printers will print anything that gets FTPed to a certain directory on them.
We used this to get past the print credits that our university exposed on us, but if your service outputs to a ps then you can just ftp the ps file to the printer.
We are using DevExpress' XtraReports to print from a service without any problems. Their report model is similar to that of Windows Forms, so you could dynamically insert text elements and then issue the print command.
I think we are going to go the third party route. I like the XSL -> HTML -> PDF -> Printer flow... Winnovative's HTML to PDF looks good for the first part, but I'm running into a block finding a good PDF printing solution... any suggestions? Ideally the license would be on a developer basis, not on a deployed runtime basis.
In answer to your question about PDF printing, I have not found an elegant solution. I was "shell" ing out to Adobe which was unreliable and required a user to be logged in at all times. To fix this specific problem, I requested that the files we process (invoices) be formatted as multi-page Tiff files instead which can be split apart and printed using native .NET printing functions. Adobe's position seems to be "get the user to view the file in Adobe Reader and they can click print". Useless.
I am still keen to find a good way of producing quality reports which can be output from the web server...
Printing using System.Drawing.Printing is not supported by MS, as per Yann Trevin's response. However, you might be able to use the new, WPF-based, System.Printing (I think)