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.
Related
I've been struggling in the last few days, trying to write a Word document.
I've tried downloading DocX by (Novacode) which was not a big success, then moved to Microsoft.Office.Interop.Word library which was better but still, not a huge success.
The problem is that I'm trying to write a Right-To-Left document, which is of course mixed with different punctuation. The moment I add punctuation the entire line is reversed.
I get many lines written from Database, write them the way they are in the document, and I can not manipulate them, unlike titles and stuff, which I can manipulate, reverse stuff and get the lines the way I want, after struggling.
I've seen some answers saying I should use a specific char which 'tells' the reading algorithm it is about to face a Right-To-Left line, but here most data is derived from database.
Has anyone faced that kind of problem and can give some advices?
To whoever finds it relevant, and none of the above helped, I found this answer the best for Right-To-Left documents:
oDoc.Paragraphs.ReadingOrder = Word.WdReadingOrder.wdReadingOrderRtl;
Did you try with the Open XML SDK and using the BiDi class?
http://msdn.microsoft.com/en-us/library/dd452407(v=office.12).aspx
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 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).
I have asp.net app in which I need to edit a word document and than send that document in email as an attachment.
I would like to know what will be the best way to edit the word document and than use it.
The document already has data and there are few variables such as "company name", "date", "amount", etc that I am searching in the document and I am replacing them with values from within the code.
The code works great when I am running it locally but from some people I received answers that editing word document on the server shouldn't be the way I am doing now but I need to use either openxml to edit the document or google docs.
Any idea what's the best way to tackle this?
I would vote for OpenXML, but be prepared to spend a good day or two reading how to use the API for .NET and be patient. =)
I remember using this tool -
http://openxmldeveloper.org/resources/dotnet/m/cc/303.aspx - quite a bit to find the relevant parts in the document to modify. You basically load a Word document and can "drilldown" to find the parts you want to modify. You can actually write some pretty clean code to search the document for your textual markers and then replace them with data.
(I hope I understood the question correctly. You said you already had working code, so I wasn't sure what the question was.)
You can use the Open XML Format SDK as per http://msdn.microsoft.com/en-us/library/dd440953%28v=office.12%29.aspx
For what you're doing though, I think your approach is fine.
I have a fair amount of screwdrivers, but if I noticed a lose screw in the stool in front of me, I might just use the knife on the table because it will do the job perfectly adequately and save me a trip to the toolbox. It's not a tool designed for that job, but it is a tool that would do the job just as well and with less effort.
Now, if I decided to set about a day's worth of DIY with only the knife instead of the set of screw-drivers, that would be going to the other extreme. Here I'd have long-ago crossed the line where using the tools designed for a given job would have made my life much easier.
It's just the same with software tools.
One of the very points of XML formats is that we can do simple tasks with it treating it just as text. Yeah, we none of us want to be the guy with a 3-page-long regular expression with which they're trying to parse a complicated XML document, but when the problem naturally breaks down to a simple text substitution, do a simple text substitution.
I'm starting to wonder if this is even possible. I've searched for solutions on Google and come up with nothing that works exactly how I'd like it to.
I think it'd benefit to explain what that entails. I work for database group at my university's IT department. My main job is to take specs of a report in a docx file, copy that over to dreamweaver, fix some formatting, and put it onto their website. My issue is that it's ridiculously tedious to do this over and over. I figured, hey, I haven't written anything in C# for some time now, perhaps I could write an application to grab a docx file, convert it to HTML, fix the CSS, stick the header, and footer from the webpage on there, and save the result. I originally planned to have it do one by one, but it probably wouldn't be difficult to have it input a list of files and batch convert.
I've found these relevant topics on how to accomplish this, but they don't fit my needs well enough.
http://www.techrepublic.com/blog/howdoi/how-do-i-modify-word-documents-using-c/190
This is probably fine for a few documents, but since it's just automating an instance of Word, I feel like it'd be slow and memory intensive. I'd prefer to avoid opening and closing an instance of Word 50+ times.
http://openxmldeveloper.org/articles/333.aspx
This is what I started using. XSLT had the benefit of not needing word to be installed nor ran for each file. After some searching I got a proof of concept working. It takes in a docx file, decompresses it, grabs the document.xml from that, and uses the DocX2Html.xsl file I scavenged from OpenXML viewer. I believe that was originally provided by MS for sharepoint servers to provide the ability to render word documents in a browser. Or something along those lines.
After adjusting that code to fit my needs, and having issues with the objXSLT.Load () method, I ended up using IlMerge to make the XSL into a DLL. No idea why I kept getting a compile error when using the plain old XSL file, but the DLL worked fine, so I was satisfied. Here (http://pastebin.com/a5HBAakJ) is my current code. It does the job of converting docx to HTML just fine (other than random spaces between some words), but the result file has ridiculously ugly HTML syntax. An example of this monstrosity can be found here (http://pastebin.com/b8sPGmFE).
Does anyone know how I could remedy this? I'm thinking perhaps I need to make a new XSL file, as the one MS provided is what's responsible for sticking all those tags and extra code in there. My issue with that is that I don't know anything about how to do that. Perhaps there's an alternative version already out there. All I'd need is one that will preserve tables and text formatting. Images aren't needed.
This looks like just what you need: http://msdn.microsoft.com/en-us/library/ff628051(v=office.14).aspx
The author Eric White blogged about his experiences developing that tool. You can see that list of posts on his blog here: http://blogs.msdn.com/b/ericwhite/archive/2008/10/20/eric-white-s-blog-s-table-of-contents.aspx#Open_XML_to_XHtml
Since I'm a big fan of Aspose.Words, a commercial library to create/process Word documents, I would do something like:
Open the Word document with Aspose.Words.
Save the Word document as HTML.
Use something like SgmlReader or HTML Agility Pack (or even Regular Expressions if it is suitable) to remove unwanted HTML tags/attributes.
Since you wrote you work at an university, I'm not sure whether commercial packages are an option, though.
Hi not sure what the rules are on promoting your own solutions, so do let me know if I am out of line.
I am a web developer who had the same issues, so I created my own tool:
http://www.convertwordtohtml.com
We are also working on a new version that will have even better conversion quality and one click conversion eg you can right click on a word file and it will be directly converted to html and the code placed into the clipboard. The current version also supports command line access and the new version will have a server version to.
There is a free trial version downloadable from the site , and if you have any questions do contact me any time.