How to pass data gathered in PHP to C#? - c#

I've written a webpage (HTML & PHP) where a user can fill in various data into a form (using text-inputs and checkboxes). This data should be added to an already existing .docx template (MS Office Word).
Now I chose PHP because I thought PHPWord would offer the solution to all my needs... but it failed me, and I am not clever enough to adapt to the code make it work somehow. So I looked for another Library that could actually insert tables and images in .docx Templates and found DocX (http://docx.codeplex.com/). But this Library is design for .NET. Now I'm hoping DocX will offer the solution I need or my boss will hang me for wasting time.
So on to the question:
I somehow need to port the data gathered in the webpage from PHP to C#. But I'm not entirely sure how one should go about doing this...
I thought maybe I could transform the data into JSON or XML and somehow read that into my C# program. But I don't understand how to "pass on the data"... do I write to a file and read that file every 5 seconds? Do I create some kind of socket/listener on a certain port? Can I somehow trigger an event in C#? My programming knowlegde is lacking...
Could someone please push me in the right direction?

Related

Generating report or spreadsheet from simple XML listing of data

I have XML objects that hold form data from a web application. These are as simple as can be for an xml format, a demonstrative example would be:
<data>
<patientFirstName>Bob</patientFirstName>
<patientLastName>Bobson</patientLastName>
</data>
and unfortunately due to humans beyond my control, roughly 150 other potential fields for the current "document".
The primary goal is to transfer this data from XML to a more "human-friendly" format such as a spreadsheet or PDF, etc..
I have tried using a DataSet as the source for a DataGrid and producing an html table. This works for a browser, and technically loads in Excel - but Excel gives a file type error, as the file is not in Excel format, it is literally an HTML table.
Is there any way to use the .net framework, or other MS objects whether managed or (preferably) unmanaged to take XML or a DataSet and turn it into a useable file format by typical office applications?
Is there a way to use SSRS without SQL queries or files? My big issue is this is a small Information System that does many things dynamically. I have seen examples of creating Excel spreadsheets using a file on the disk...but it is 2019 - I will allow my code to create or read files, the concept of a file is quite obsolete and a major source of security dilemmas.
In a perfect world I would want to create a decent looking report form template and simply bind certain nodes to their respective node in the XML. This would seem like something that many people would want to do, and as if it would be easy to implement, but search as much as I may and I find 99 terrible ways to pretend to make an Excel file and not 1 decent one. SSRS would seem like a lovely option if I could request to use a premade template and pump XML into it or a DataSet from a middleware server - though my issue is that it seems to be dumbed-down to the point it is designed to do ALL the work in some not-very-flexible manner.
If all else fails, might there be some MS functionality for pagination that I can use to create my own mini-report generator? I feel I may be forced to..
Please understand I am not looking to hand-parse markup in C# - in unmanaged C++ I would consider it, but C# becomes very slow when you start doing things "by hand" as opposed to using objects and their methods.
.net 4.5+

Using a C# winform with Access to fill a template and convert it to PDF

Im working on adding an estimating feature to my business productivity software and was looking for some general ideas. I currently hand type the estimates into a template I made in an Open Office Document.
I would like the template to be filled in on submission of the form and then have the template converted to PDF. How could I best achieve this? The program is written in C# using Access. Basically, I'm looking for the most efficient way to do this. If I have to scrap my Open Office template for something else that is fine.
I will also need to be able to acess the fields and repopulate a form to modify the estimate if necessary.
Thanks in advance for pointing me in the right direction!

Writing to an Excel file from SQL Server Database

Currently, I need to be able to retrieve values from an SQL Server DB, populate an Excel file according to a certain template, and then allow the user to download the file. I also need this this certain template to be customizable, in the sense that the user can add new fields, and remove fields.
I understand that there are a couple of approaches I can take: using .xlt, and using C# directly. With C#, the user will need to interact with a UI, which will then populate a ExcelTemplate table in the SQL Server. This ExcelTemplate table will then be used when the user wishes to download a new Excel file.
I know all this stuff may sound kinda abstract, so please do tell me if there are some places I need to elaborate/clarify. Thanks a bunch, man.
EDIT: Sorry, I kinda missed this part out, but I'd prefer to allow the user to customize these Excel templates via a Silverlight UI.
You can create Data Sources in Excel and pull the data from MS SQL Server.
You can use MS Reporting Services which allow to get reports in MS Excel format. In this case users can use Report Builder to customize the reports.
For pulling down data from SQL Server and dumping it into Excel, you can use Officewriter. It has Reporting Services integration and supports generating .xls and .xlsx documents. There's also a template component that basically does what you're trying to do. The templates are actually Excel documents, so the users can edit them directly in Excel. Not Silverlight, but not bad. You can try an eval for free.
DISCLAIMER: I'm one of the engineers who built the latest version.
at the end of the day I think I'm gonna spend some time building a customized dashboard. It won't be generic, but rather focused on the existing database.
I know this answer is kinda vague and all, but I'd like to say thanks for all the help :) it'd be great if there are dynamic solutions for this in the future! I think...

scrape to excel file

I am working on a program to get proxylists from the web to a datagridview and then add an option to export the data to csv.
I am really a noob and want to know the way of doing so without connecting to a SQL DB. I just want it to get the data (done this already), show it in columns locally and export to csv as an option.
I heard it can be done somehow with LINQ.
Can I see an example? I just can't seem to find anything out on the web..
Also exporting to csv would help..
Thanks!
Check this library out, worked like a charm for me. Has some examples on there for you.
http://www.codeproject.com/Articles/25133/LINQ-to-CSV-library
One of my first projects as a programmer was something along these lines, so GOOD LUCK!
At work we use the FileHelpers open source library for CSV manipulation. It is super easy to use and extremely quick to develop against with a small learning curve (which is really important when using 3rd party libraries).

Reading Word Documents stored in Oracle DB as a BLOB object using C#

We store a word document in an Oracle 10g database as a BLOB object. I want to read the contents (the text) of this word document, make some changes, and write the text alone to a different field in a C# code.
How do I do this in C# 2.0?
The easiest logic that I came up with is this -
Read the BLOB object
Store it in the FileSystem
Extract the text contents
Do your job
Write the text into a separate field.
I can use Word.dll but not any commercial solutions such as Aspose
I assume that you already know how to do steps 1 and 2 (use the Oracle.DataAccess and System.IO namespaces).
For step 3 and 5, use Word Automation. This MS support article shows you how to get started: How to automate Microsoft Word to create a new document by using Visual C#
If you know what version of Word it will be, then I'd suggest using early binding, otherwise use late binding. More details and sample code here: Using early binding and late binding in Automation
Edit: If you don't know how to use BLOBs from C#, take a look here: How to: Read and Write BLOB Data to a Database Table Through an Anonymous PL/SQL Block
This keeps coming up in my searches, so I'll add an answer for the benefit of future readers.
I highly recommend avoiding Word automation. It's painfully slow and subjects you to the whims of Microsoft's developers with each upgrade. Instead, process the files manually yourselves if you can. The files are nothing but zipped archives of XML files and resources (such as images embedded in the document).
In this case, you'd simply unzip the docx using your preferred library, manipulate the XML, and then zip the result back up.
This does require the use of docx files rather than doc files, but as the link above explains, this has been the default Word format since Office 2007 and shouldn't present an issue unless your users are desperately clinging to the past.
For an example of the time savings, Back in 2007 we converted one process that took 45 minutes using Word automation and, on the same hardware, it took 15 SECONDS processing the files manually. To be clear, I'm not blaming Microsoft for this - their Word automation methods don't know how you will manipulate the document, so they have to anticipate and track everything that you could possibly change. You, on the other hand, can write your method with laser focus because you know exactly what you want to do.

Categories

Resources