Visual Studio Extension using TextMate for SQL - visual-studio-extensions

I would like to add some additional keywords to the syntax highlighting for SQL files.
Ive installed the TextMate Grammers Template and have imported the SQL.plist file as the basis.
I can add the words I want to this. All good.
However, this only works if I add a new extension to the list (E.g. .ds files)
.ds files show with SQl syntax highlighting and highlight correctly my additional words.
.sql files do not. Assume because the default SQL highlighting takes over.
How do I make my SQL files in Visual Studio use my new extension to highlight the new words I've added?
Many thanks

Related

ASP.NET generated excel file has different format than extension

I have a web application made in old asp.net 2.0. I need to generate excel file with specific formated table (the best way if I can load the template and only put data in code behind). To do this I'm trying to use this library CarlosAg.ExcelXmlWriter:
http://www.carlosag.net/tools/excelxmlwriter/sample
And the final file is generated very well, but when I'm trying to open it in MS Excel warning popup appear with information that file has different format than the extension (xls). And also question if I want to open it if I trust the source of file. When I click yes, the file opened properly. On the other pc with different version of Excel, there's also warning, but different - file is broken and cannot be opened, the same in mobile (no possibility to open). What is interesting - I can open that file properly without any warnings in different office program, ex. WPS Office.
So I make two steps back and try to open just simple file generated by the sample of Carlos library and effect is the same. Is there any chance to "fix" the file in code behind so MS Excel could also open it properly without any warnings?
Dim book As Workbook = New Workbook()
Dim sheet As Worksheet = book.Worksheets.Add("Sample")
Dim row As WorksheetRow = sheet.Table.Rows.Add()
row.Cells.Add("Hello World")
book.Save("D:\Folder\test.xls")
You have to give the file extension xlsx.
The older xls is in fact the legacy (closed) binary format of office files.
However, since office 2007, Microsoft has adopted a open xml format for ALL office documents (well, ok, outlook pst, and MS-Access are exceptions). In fact, if you take any office document (word, power-point, excel) etc., try renaming the xlsx document as a zip file. You find that you can now open the zip archive, and you can see/look at and even modify the xml in that document.
(do try this rename as a zip file for fun and giggles - you see how you actually don't even need any 3rd party tools to open, play with, and mess with the content in the zip archive (so, all office documents are in fact a simple zip archive!!!).
So, newer office file formats are in fact xml markup - and you can modify it!!
Anyway, without a doubt that library you are using thus uses the above feature/fact of office documents now being xml formatted and NOT a propriety Microsoft binary format - you can in fact modify such documents now on ANY computer that is able to open a zip file, and modify text files.
As a result, you are giving the document name a legacy binary file name (xls), but opening a xml formatted file (plain text), and thus Excel is detecting this fact/issue. So, you need to give that document the open office xml format extension (xlsx).

Automatically capitalize keywords (for SQL)?

I'd like to automatically replace keywords like select with SELECT. Is there a package that does this in Atom?
I know that there's the package pg-formatter, which works great for .sql file. Unfortunately my SQL queries are usually embedded in .py files, which pg-formatter will mess up.

Generate Word (docx) Files with from Templates (dotx) on Server Application

I'm currently working on a project where I have to transfer an existing VB program into a Server Application using ASP.NET.
While I had success doing that there's one thing that I'm struggeling with:
The VB Program was using Microsoft Word Interop to generate Excel files and fill Word Templates with data. While i managed to be able to generate the files locally with Interop I can't get it to work for somebody that is accessing the Application from a client.
I also tried using OpenXML to solve my problem but somehow it always said that the file is corrupt after I tried to fill the bookmarks.
In the end the user shoud be able to download the Word document filled with the necessary data.
What would be the best solution for this problem?
If you have mostly the same document structure, you can prepare the whole document in Word. Set placeholders in the document like {Placeholder1} {Placeholder2}, parse the XML and Replace the Placeholders with your text, so you must not generate the whole document structure. Only Replace the Placeholders with your text.

How to find all strings from a list of strings that do NOT appear in any of my source files?

I've got a bit of a messy DB. There are a lot of stored procedures that I strongly suspect are not used. I can easily get all their names in a text file, one name per line. Now I would like to search all through my code files to find which ones are mentioned and, more importantly, which ones are not.
How could I do such a thing? I'm using Windows 7, Visual Studio 2008 - if it matters.
Write your own small app (console app would do).
read your file, get the procedure-names inside a list, and then for each name search your code file, and log the name if you did not find the nam einside your code-files.
See System.IO.FileStream class for the easy (but not that fast) way of search a file.

Automatically adding rows to excel file template

I am running .net 4.0 asp.net app on IIS 7. I want to know if there is an easy way of adding rows to an excel 2007/2010 (not too fussed) template file that a user can download from the server.
For example, the user might check a couple of tick boxes and clicks a button on the web page. The server does a sql query on a table and comes back with the results. I have an excel file with some headings, column titles, formatting etc. on the web app's resources directory. I want to make a copy of this file, insert each of the results as a row into this file (insert first name into cell A3, last name into cell B3 etc.). And make it available for the user to save on their disk.
Since Excel (xls) format is an "Open format", I was wondering how easy/straight forward this would be. Is it a matter of loading the excel XML DOM and inserting XML elements? What are libraries I need to use?
Any help or resources would be greatly appreciated.
I did exactly this using an Excel template. You'll see how easy it is to do this using open source libraries as NPOI.
These links should help you get there:
Create Excel (.XLS and .XLSX) file from C#
Creating Excel spreadsheets .XLS and .XLSX in C#

Resources