Create multiple tabs on excel via classic asp - excel

I can export to page as excel file via this code below:
response.contenttype = "application/vnd.ms-Excel"
response.Addheader "content-disposition", "attachment; filename=test.xls"
But I want to create multiple tabs on the same excel file, how I can do it?
Thanks for helps.

You cannot do that using the response.contenttype directive. that command only transforms a page into excel so you do not have the ability to create a new page as all of your html will be read as one page.
The solution depends on what your requirements are.
Free
The only free solution I know is building a page and pushing it to the browser as an XML file. If you create the file you want in excel and then save it in an XML format, you can open that file and see how the page should be build in asp.
Pros Its free. you do not need permission to install anything to the server. You will just be passing an xml file to the client.
Cons Excel is not the default viewer for xml files, notepad usually is. Most people will not understand how to open your file in excel. This means that this method is really only good for internal applications where you can change everyone's computer to open XML files in Excel by default.
3rd Party Program
When I needed to accomplish this same task I had entertained using 3rd party programs in classic asp. I wish I could remember the program but it would have cost around ~$1,000 to use.
Pros These programs are feature rich and will allow you to do anything you could want in exporting to excel. They are also cleaner and a bit simpler to use over writing your own XML file to open in excel.
Cons Costs money. may require server permissions you do not have. Most programs require you to save the file to the server before serving it to the client
ASP.NET
You can choose to instead create a new page in asp.net and use its excel features to create the file you need.
Pros Also free. Same extensive feature set available in most 3rd programs for classic asp are available with this method.
Cons classic asp and .net are not able to communicate directly so things like password protection on the page will become an issue if that is needed. You obviously need to know or learn the .net framework. Files are saved to the server before being sent to the client.

Related

Embed Excel in a website to edit a locally stored document

Is it possible to embed google excel in my website to edit document stored locally?
My manager asked me if it is possible to integrate the Microsoft office webapp in my own website.
Clients have excel files stored on our website, we want to know if it is possible for them to open the file with a web excel page, edit the file and save the modifications. For now, they use SharePoint so it is easy for them but we intend to use an other platform.
Our client can have all the license we need.
I searched but I didn't find any solution.
I know you should be able to do this with ASP and the .Net Framework. SharePoint uses ASP pages, so you may try to do something simpler.
If you go over the Internet you'll see several solutions because people do this too.
e.g. a thing you can do is to use Open XML API to do this, and it is like reading / modifying a flat file on the server. A restriction is it has to be .xlsx / 2007 format onward.

Is it allowed to generate temporary files?

I have not yet submitted any Office add-in.
For the add-in I am developing, a JavaScript function will generate a temporary .txt file, which will be treated by another JavaScript function. Does anyone know if the server of Office Add-ins permits of generating temporary files like that?
Is there any example in https://github.com/OfficeDev that uses temporary file?
If it is not allowed, which would be the data type to represent large unstructured information (like text) to be passed among JavaScript functions?
Since all web-based Office add-ins use JavaScript, you have no interaction with the local PC nor the web server where the add-in's pages are hosted. If you need to do file manipulation you could for example call REST endpoints (via Ajax from your JavaScript) on your web server which could use server-side code (such as the ASP.NET Web API, NodeJS, etc.) to do the file work and return results to your JS code.

Want to write HTML Content on a WebPart for Sharepoint

In developing Sharepoint Webpart, if I need to add HTML Content to the output of my Web Part, right now I do it like this :
this.Controls.Add(new LiteralControl("<html content>");
If I need to output a large HTML Content with Data in it, I need to instantiate a lot new Literal Contents then there is a problem, that it will make my process slow and memory consuming.
Please tell some alternatives to this approach.
Just use a visual webpart where you get to use the WYSIWYG designer and if it needs to be deployed in a Sandboxed environment you can download one from the Power Tools extension.
Oh God, writing all that markup from code is a nightmare. By using a visual webpart you can make amazing looking webparts.
If you are going to use your own scripts or CSS files just create mapped folders for them and set the deployment option to their path.
You can approach this problem by analysing webpart rendering time by using Developers DashBoard (only in SharePoint 2010). To enable this you should use powershell code like this:
$svc=[Microsoft.SharePoint.Administration.SPWebService]::ContentService
$ddsetting=$svc.DeveloperDashboardSettings
$ddsetting.DisplayLevel=[Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::OnDemand
$ddsetting.Update()
When DD is enabled use this instruction to chceck your rendering time on server side:
http://blogs.technet.com/b/speschka/archive/2009/10/28/using-the-developer-dashboard-in-sharepoint-2010.aspx
You can also use monitored scopes (SPMonitoredScope) to check parts of your code which can take most part of rendering.

Running Excel automation locally or on server

Wanted some opinions on which method is a better practice. We have a sales report that MUST be generated in a very specific format (down to the row colors and fonts).
I already have written a macro which pulls from our database and populates the entire workbook in about 15 seconds. The question is how should it be populated?
1) Process server-side: Users initiate the request on the intranet page. ASP.NET opens the workbook template, executes the macro and serves back the final sheet.
2) Process locally: Users download the blank template, run from their desktops which automatically connect to the database.
I like the first one because I can enforce the template, timing, users, and security of the data. But is running Excel automation on an internet web server recommended? I like the second option, but I'm afraid of losing standardization as template sheets begin floating around the company.
As for server side:
I highly.. HIGHLY.. recommend checking out the OpenOffice/LibreOffice XML format for spread sheets.
You can use the localc binary in headless mode to convert the XML file to XLSX or what have you. I use it to create PDF files instead of using ReportLab.
Alternatively here are some other projects that attempt to write to Microsoft formats directly:
http://pypi.python.org/pypi/xlrd
http://pypi.python.org/pypi/xlwt
As for client side:
If you expect the user to be only using Excel and not any other spreadsheet software then go ahead and use an ODBC data source. ODBC will have to be configured per user unless you use some fun VBScript to pull the data from an HTTP server every time it is loaded. There is also the option of making an XLS spreadsheet that simply holds the data and including it into an XLS document as well which would be both a server and client XLS requirement.
Go for server side. Makes information simple to archive and share and will most likely be multi-platform as well.
If you like to use your first option, then you want to avoid using VBA on an installed instance of Excel on the server. This is extremely resource intensive and does not scale well. Instead, if you are writing ASP.NET code, then you should try using the Microsoft Office Interop functionality that is built into the .NET framework. It should possible to adapt your existing VBA code to run under ASP.NET with some changes, but you will have a much more reliable product in the end.
Example Code
However, as #whardier points out in his response, if this were for a large scale or public site, the suggestions he makes would be much more suitable and would scale much further.

Is there a library that takes Microsoft Office files (Word/Excel/ppt) and renders images of them?

I'm building a webapp, and I need the ability for users to view Word/Excel/PPT files in the browser (these files are stored server-side). This is to offer them a quick way to preview the document without needing to download it and launch Microsoft Office.
Pretty much looking for the "View" feature for email attachments in Gmail. I'm assuming that Google is somehow rendering the doc formats into images and displaying them in the browser.
Is there a way to do this in OpenOffice?
I do not know whether you can do this with OpenOffice, but SpreadsheetGear for .NET will let you open an Excel workbook and get an image from ranges of cells or charts.
You can see some examples of this here.
Disclaimer: I own SpreadsheetGear LLC
Here is a way to do generate images of office files, doing all of the processing on your server:
On server-side, run OpenOffice in server mode (no UI, just the API is callable).
Call the OpenOffice API to translate any office file to PDF (See how the open source software Alfresco does this).
Then convert PDF to PNG using ImageMagick.

Resources