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).
Related
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?
I have processes running on Windows XP/7. They generate weekly .csv data files. I have a bunch of excel formulas that crunch the numbers for each .csv file produced for the week separately and then when adding the weekly data to the one big spreadsheet containing all the data put together.
The number of rows varies each week and for each process. So I can't hardcode that number in my dozens of formulas. So right now I go through this stupid process of manually entering the formulas each week into the .csv files.
There's got to be a way of automating this. Just now I quickly looked into doing this through C# or VB code. Could somebody recommend the best way to do this. Is C# or VB the right way to go? If so, any hints on how to put it all together - what's the model to use? For example, would it look something like this:
C# module reads in .csv data file
C# module creates an Excel spreadsheet and populates it with the .csv data
C# module runs my formulas on the all the rows.
Is that how one would approach it? Is there a better way for somebody who has very limited knowledge of C# or VB? I know Java and C++.
Any advice would be highly appreciated.
Thanks
From your explanations in comments, it appears that having a series of template Excel sheets would greatly facilitate the task.
So, for each process that generates data, you say the formulas are always the same, meaning that the columns are always the same (am I right?).
So, even if you don't know how many rows of data, you can still either create a template where only the first row is filled with formulas, and then you simply copy that row over and over, filling it with data as needed, or, you could fill a relatively "comfortable" number of rows with those same formulas, and fill in the data.
There are tons of atricles on how to Interop with Excel, so it's beyond my intent to provide you with specific code, but the idea is good.
If I can allow myself, I have worked in the past with a very interesting tool call Flexcel Studio for .NET, and I have found it to be of great help when it came to generating Excel sheets based on such templates.
Cheers
As others have suggested, I would recommend performing the calculations outside of excel if possible. There are plenty of stats libraries out there that are friendlier to work with than going through the hassle of moving data into excel, applying formulas to cell ranges, and so on.
If you really want to go the excel route, you can either use open-source libraries such as EPPLUS (.NET) or POI (Java) to work with .XLSX files directly. Some libraries do not support function evaluation so you will need to consider this when deciding on a library to use.
If you go with COM interop, you should read about about the following: Considerations for server-side Automation of Office.
As for the C# or VB (if not java with POI), I would go with C#. C# syntax is similar to java.
There might be a really simple solution to this problem.
Add 1 piece of auxiliary data to the .csv file either programmatically when running my process or when creating the .xlsx file (with all the formulas) from the .csv file. The auxiliary piece of data is the row count which will be in some known location.
Then modify all my formulas to use the INDIRECT function to specify the range using the cell
with the auxiliary piece of data.
I think that might work.
I have built a very simple windows form application using C#. But I am stuck here and could not find any help anywhere.
What my simple application does is that it queries out the information in the groupbox which has textboxes labels and buttons. I would like to export or convert the data from in the groupbox into the pdf.
Is there a way to implement that??
Thank you so much in advance~
You may want to have a look at http://www.pdfsharp.com/PDFsharp/. It's a pretty good framework for what you need.
Good luck
There are so many options, following SO Link provides the solution and it is working it seems
convert windows form to pdf file
Other Solution
Use following code to take screenshot
http://www.developerfusion.com/code/4630/capture-a-screen-shot/
Use PDFSharp to save as PDF
there's really a ton of different solutions for this, but you will almost absolutely need a 3rd party library for what you're trying to do. Google around for a pdf library for c#, as there are several.
EDIT: some possible solutions may be PDFjet, PDFsharp,ABCPDF (do note, if this is part of a commercial application, make sure that the licensing allows use for it)
Is there any tool out there which will format excel formulas in such a way that they are more easily decipherable?
I need to convert some complex excel spreadsheets people have made to C# applications and sitting there looking at one line excel formulas is relatively troublesome. Primarily I'm looking for something that can rewrite them to pseudocode or a more readable programming language.
The closest thing I could find was http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html but this still does not help all that much.
Sean Cheshire's comment is probably the best answer you're going to get:
Excel Formula Beautifier
It has a feature that allows you to convert to javascript.
The one thing it seems to be missing is a feature to do a batch of formulas at once (which would save a lot of time if converting a whole sheet with "Show Formulas" turned on). I added a request for this.
Given how the app works now, if you try pasting a batch into the single-line input field, you may still get a result that's at least somewhat useful. I recommend giving it a try.
I have an excel spread sheet (well, hundreds of them) which I need importing into a database.
If the excel data was in a nice uniform format I would simply save them out to CSV, read them in using something like LINQ to CSV and save the required data away.
However, the excel spread sheet is 'uneven' in that different groups of cells contain different data.
I need a way of grabbing the data and then working with cell references to grab the bits I need and save them to the database.
What's the best way to achieve this?
Thanks
UPDATE some more information
I have numerous spread sheets, all identical in structure that need to be imported into a database. The import is not simple in that different chunks of data from the spread sheet will go into different tables. The excel document itself contains a few sections (basically question / answer) type data. For each different section I need to grab the data, shape it into a form that makes sense in terms of the database and save it.
Ideally I would like to create a quick little WPF app that will let me select a spread sheet hit a button and perform the import.
You could use the Excel Object Model to read the data if you do it in a non web environment.
See for example How to automate Microsoft Excel from Microsoft Visual C#.NET.
If it has to be inside a web application. I suggest to use Aspose Cells.
Turn the Excel Spread sheet into an ODBC (Open Database Connectivity) Data Source so you can access it just like you would any database:
http://www.datamystic.com/datapipe/excel_odbc.html
Then access it just like any database using ODBC:
http://msdn.microsoft.com/en-us/library/system.data.odbc.odbcconnection(v=vs.71).aspx
When the data is not uniform, it is often better to keep your approach as simple as possible in the first instance. Start with vba and the "Range" object (which is part of the excel object heirarchy). From there you can increase the level of automation and in most instances reuse this "Range" work.
avariable = Range("A2:A5")
That notiation is not going to change very much. It wont matter what final target language you use (language: C# / vba / etc).
There are a number of other ways of going about this -- java based / xml based / c# based / and a few other really cool ones that only apply to certain niche situations. If you can provide more information about your use case, then perhaps I can suggest some more things to try.
Q & A
example link for automation from C#: http://support.microsoft.com/kb/302084
You should probably take a look at Microsoft's Visual Studio Tools For Office (VSTO), which handles a lot of the unpleasant COM/interop stuff for you.
To those who may be interested I ended up using LinqToExcel:
http://code.google.com/p/linqtoexcel/
Did exactly what I was after with minimal fuss. Excellent