I was using a company called ActiveXLS to save native XLS files with charts from Classic ASP but they seem to have closed down.
Can anyone recommend an alternative classic asp excel component I can use?
CSV or HTML (with XLS content type) export is not sufficient for what I need.
You can access the MS Excel DOM using Classic ASP. There are definite limitations of this approach for a web based environment but I have used it for low volumes.
Here's some sample code to illustrate:
Set oApp = Server.CreateObject("Excel.Application")
Set oBook = oApp.Workbooks.Add
Set oSheet = oBook.ActiveSheet
Set oRange = oApp.ActiveCell
' Create the header fields
oRange.Cells(1,1) = "Column 1"
oRange.Cells(1,2) = "Column 2"
oSheet.Range(oSheet.Cells(1,1), oSheet.Cells(i,j)).Select
oApp.Selection.Columns.AutoFit
oSheet.Cells(1,1).Select
oBook.SaveAs "filename.xls"
oBook.Close
oApp.Quit
Set oApp = Nothing
This does require Excel to be installed on the server that builds these files.
Related
Thi is my first question.
I'm developing an exportation from our SQL based ERP to smartsheep.
We are developing in .NET (VB).
I'm creating / uploading sheet and creating data in row without problems.
My actual and almost last trouble is to be able to set a specified workspace...
Example.
I Upload a template XLSX file to smartsheet. I populate it with all the data i need to put inside, than (and here we are) i would like to set to the uploaded Sheet a specific workspace...
I'm using nuget smartsheet-csharp-sdk Version 2.126.0
Thank you for any reply.
This is more or less my code:
Dim smartsheet As SmartsheetClient = New SmartsheetBuilder().Build()
Dim sheet As Sheet = smartsheet.SheetResources.ImportXlsSheet(Dim XLSFILENAME as string, Nothing, 0, Nothing)
Than i have my build / upload rows code...
but no idea on how to set the workspace....
With the import ImportXlsSheet you can't set a destination, the sheet will be created at the root (home) or smartsheet.
You've to create the sheet, and by the response you should have access to the sheetId created.
With a second call to the API, move the sheet to the specific workspace. see also : https://smartsheet-platform.github.io/api-docs/?csharp#move-sheet
Using vb.net, visual studio 2013 and excel 2010.
I have a web page and when a button is clicked values are passed from the page to excel ( a presaved formatted copy). I then want to run the solver add in (which I have also preconfigured). I have been searching for a while now and cannot find a way of doing this.
The below is the code I use to open the excel application
Dim xlApp As Excel.Application
Dim xlWorkbook As Excel.Workbook
Dim xlWorksheet As Excel.Worksheet
xlApp = New Excel.Application
xlApp.Visible = True
xlApp.DisplayAlerts = False
xlWorkbook = xlApp.Workbooks.Open("c:\temp\RTO.xlsx")
xlWorksheet = xlWorkbook.Sheets("Optimiser")
Another curious problem that may be related is when I open excel from the web page the solver addin is enabled in excels options but does not appear in the data ribbon tab. If I disable and enable it in the options it comes back.
UPDATE
I tried the following code
xlApp.Run("C:\Program Files\Microsoft Office\Office15\Library\SOLVER\solver.xlam!Auto_Open")
But it errors with the following
Additional information: Cannot run the macro 'C:\Program
Files\Microsoft Office\Office15\Library\SOLVER\solver.xlam!Auto_Open'.
The macro may not be available in this workbook or all macros may be
disabled.
Ok, so
1) a website that populates excel with data and then streams the excel to the client.
2) the client then fill out or manipulates stuff in the excel.
3) Then clicks a button to solve and perhaps submit the excel...(where you are stuck)
Step 3 could be accomplished with a small 'one click application ' aka 'clickonce', whereas the application is online and served from your site. You could take one cell of your excel and have it open IE and point to the installer, and even pass a parameters (be sure to allow params to pass in the app) as to where the excel was located. Then the app could interop with the excel and do its stuff, perhaps even deliver data back to the server.
After further research and thinking about my problem, I came up with the following.
I cannot find any help about triggering solver from within my vb.net code but you can trigger a macro.
First I added the following code which loaded solver.xlam into excel once it had launched.
xlWorkbook.VBProject.References.AddFromFile("C:\Program Files\Microsoft Office\Office15\Library\SOLVER\solver.xlam")
I then created a macro in excel to launch solver. Once done I added the following line of code into my web page. Runsolver is the name of the macro.
xlApp.Run("RunSolver")
Hope this helps someone else down the line
I'm working on a VS 2008 asp.net webforms application in which it contains an existing RDLC (Client file, and NOT the RDL Server side file).
The problem is upon exporting to excel, all of the worksheets are not named properly, i.e. Sheet1, Sheet2, etc. I have found many examples on exporting data, on SQL Server 2008 R2 feature of RDL, however I am in need of a RDLC solution?
Does anyone know about how to either "fix" this or do some sort of post processing to rename the tabs so the customer doesn't end up seeing Sheet1, Sheet2, Sheet3,etc.?
Application is choosing the path of the RDLC file
Adds DataSource
Chooses xls
Does all the Responses
I see this Stackoverflow link How to get named excel sheets while exporting from SSRS, however:
Can't do the Macro
Can't do the export as SSML
I am NOT using RDL / SQL Server 2008 R2 SSRS, thus the other answers are misleading for people using the RDLC
Sheet renaming isn't supported with the version of RDLC report. I'm guessing you can't upgrade. So here's a work around: Save the report to a file as normal. Then open it again using Microsoft.Office.Interop.Excel or any other Excel library to rename the sheets. Once you do this save and you're done.
using Excel = Microsoft.Office.Interop.Excel;
Excel.ApplicationClass xl=new Excel.ApplicationClass();
Excel.Workbook xlBook;
Excel.Worksheet xlSheet;
string filePath = Server.MapPath(#"\report.xls");
xlBook = (Workbook)xl.Workbooks.Open(filePath,Type.Missing,
Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing
,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
xlSheet = (Worksheet)xlBook.Worksheets.get_Item(1);
xlSheet.Name = "New Sheet Name";
xlBook.Save();
xl.Application.Workbooks.Close();
List of different libraries that you can use if this one doesn't work for you: Free Libraries
1. Close XML Library - http://closedxml.codeplex.com/documentation
2. Open XML SDK - http://msdn.microsoft.com/en-us/library/bb448854.aspx
3. NOPI - http://npoi.codeplex.com/
4. CarlosAG - http://www.carlosag.net/Tools/ExcelXmlWriter/
Paid Libraries
5. Spreadsheet Gear
6. Smart XLS
7. Office Writer
8. Spire
I would upgrade to the RDL 2010 schema - it supports Excel Named Sheets (amongst other useful enhancements):
http://msdn.microsoft.com/en-us/library/ee960138.aspx
Your not going to be able to do it.
http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/54caf25b-b17b-474c-aa47-fc884f90af03
http://go4answers.webhost4life.com/Example/reportviewer-eport-excel-naming-sheets-157612.aspx
http://forums.asp.net/post/4140154.aspx
This may help for post processing using excels xml dialect:
http://spacefold.com/lisa/post/Changing-the-Sheet-names-in-SQL-Server-RS-Excel-QnD-XSLT.aspx
I have been struggling with this issue for some time now.
I have a web interface where I create projects, with this you should be able to upload multiple documents to the server, which is attached to the project they belong to.
So far I made it work with only uploading one file at a time.
My idea was maybe to add the "file" objects in an arralylist and then bind it to a gridview and then upload it to the server?
I know this sound a bit confusing, but I'm confused also!
This is how my method look like when I upload a single file to the server and also save the file's ID, name and context in the database:
File file = new File();
Projects_Overview po = new Projects_Overview();
po.Name = TextBoxName.Text;
po.Time = time;
po.Owner = TextBoxOwner.Text;
po.Responsibility = TextBoxResp.Text;
po.Created = datecreate;
po.StartDate = datestart;
po.FinishDate = datefinish;
po.ETC = dateETC;
po.Description = TextBoxDesc.Text;
po.Comments = TextBoxComments.Text;
po.Remember = TextBoxRemember.Text;
ie.Projects_Overview.AddObject(po);
ie.SaveChanges();
if (uploadFile.HasFile)
{
string filepath = uploadFile.PostedFile.FileName;
string fileName = Path.GetFileName(filepath);
file.Context = Path.GetFileNameWithoutExtension(uploadFile.PostedFile.FileName);
file.Extension = Path.GetExtension(uploadFile.PostedFile.FileName).Replace(".", "").Substring(0, 4);
file.FileName = Guid.NewGuid();
string fileSavePath = Server.MapPath("") + "\\Wordfiles\\" + Convert.ToString(file.FileName) + ".upl";
uploadFile.PostedFile.SaveAs(fileSavePath);
file.ProjectID = po.ID;
ie.File.AddObject(file);
ie.SaveChanges();
Can someone tell me how to "attach" multiple files and then save them in the folder along with the other data as I posted above?
Cheers
I believe that HTML 5 has the built-in capability to handle multi-file uploads (where HTML4 does not), but I have not worked with HTML5 yet. With HTML4, you must use an external control (typically either javascript or flash), as there is no built-in mechanism to allow multi-file uploads.
I did write a multi file upload page that works with HTML4 or HTML5 utilizing PLupload (an external control) to perform the file picking. I had to find a generic file handler to interface the control to the .aspx upload page. I think that I found that here.
It took a couple hours to implement, but it's worked great.
Can anybody tell me how to set the zoom factor on an Excel sheet via a ASP.NET application. I believe the Excel Sheet object has a PageSetup.Zoom property which does not seem to be working. When I generate a report in Excel programatically through ASP.NET I get the zoom factor of all sheets in the workbook as 100%.
Here is a code sample
oSheet.PageSetup.CenterHorizontally = true;
oSheet.PageSetup.CenterVertically = true;
oSheet.PageSetup.Orientation = XlPageOrientation.xlPortrait;
oSheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4;
oSheet.PageSetup.Order = XlOrder.xlDownThenOver;
oSheet.PageSetup.Zoom = 85;
Another option is ActiveWindow.Zoom as generated by a macro but it is macro-specific. The whole point of asking this question is after the report has been generated the zoom factor of all the pages in the Excel workbook should be 85%.
Any inputs would be highly appreciated.
SpreadsheetGear for .NET allows you to set the zoom factor of an Excel worksheet like this:
SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
SpreadsheetGear.IWorksheet worksheet = workbook.Worksheets[0];
worksheet.WindowInfo.Zoom = 150;
Microsoft does not support and recommends against using Office with COM Interop in ASP.NET (see this Considerations for server-side Automation of Office KB article).
You can see live C# and VB examples which demonstrate using SpreadsheetGear from ASP.NET here and download a free trial here.
Disclaimer: I own SpreadsheetGear LLC
PageSetup only affects printing. You need to use the Window Zoom. In C# it's something like:
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
xlApp.ActiveWindow.Zoom = 150;
This only affects the sheet in the active window, not every sheet. You can also set the zoom through the workbook (wbk.Windows[0].Zoom) rather than xlApp.ActiveWindow.
The way to implement this for all sheets in a Workbook object MyWorkbook is to select all of the sheets and then hit the ActiveWindow:
MyWorkbook.Sheets.Select(Type.Missing);
MyWorkbook.Windows[1].Zoom = 150;
I tested this and Windows[1] seems to give you document-level customization. I had a problem embedding this code in the workbook's Startup event, but it seems to be fine further down the line.