Test a excel file using Selenium - asp.net

I have a web application in ASP.NET and C# that exports some data on a click of a button. How to test the contents of the Excel file from the exported file in a location on a system using Selenium?
I know by saving Excel file as HTML we can open Excel sheet as a web page. But I am not able to find a way to open it from C# code.

Selenium is for automating web/http transactions and nothing else.
Read this article on MSDN that will give you some info how to work with C# and Excel: https://msdn.microsoft.com/en-us/library/aa188489.aspx
Some more brief information:
https://support.microsoft.com/en-ie/help/302084/how-to-automate-microsoft-excel-from-microsoft-visual-c--net

I was able to do that with help from google
Application app = new Application();
Workbook Wrk =app.Workbooks.Open("C:/Users/Desktop/Delete/filename");
Wrk.SaveAs("c:/Users/Desktop/InvoiceMeet.html", XlFileFormat.xlHtml);
This will covert an Excel file to a browser file. Thanks!

Related

Sharepoint 2010 API upload a file with metadata creating a new version from ASP.NET web application

How I can upload a file with metadata creating a new version from ASP.NET web application to SharePoint 2010?
Is there any way?
Thanks in advance.
There are multiple ways to upload a file to a document library.
Perhaps the simplest way is simply to copy the file to the document library's URL using File.Copy. SharePoint supports WebDAV so you can treat a library as a network folder, opening/saving files directly from any application, copying and renaming from Windows Explorer etc.
You do face some limitations though:
The full path of the file can't be larger than 260 characters and SharePoint will truncate it without warning.
The file name can't contain some characters that are valid for Windows Explorer, eg #
If you try to save a file with the same name as an existing one, SharePoint will create a new file with a slightly different name without asking
You have no control over the author and creation date properties. SharePoint will use the current date and the credentials of the user executing the code.
You can't set any metadata although you can update the file's ListItem properties after uploading.
Another option is to use the Client object model and upload the file using File.SaveBinaryDirect. This option is better than simply copying the file, as it allows you to overwrite an existing file, but you still don't get direct access to the file's properties. Uploading could be as simple as this:
var clientContext = new ClientContext("http://intranet.contoso.com");
using (var fileStream =new FileStream("NewDocument.docx", FileMode.Open))
ClientOM.File.SaveBinaryDirect(clientContext,
"/Shared Documents/NewDocument.docx", fileStream, true);
Another option is to connect to a library using the Client Object Model and then create a file using FileCollection.Add, eg
Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(
fileCreationInformation);
Check this SO question, Upload a document to a SharePoint list from Client Side Object Model on how to use both SaveBinaryDirect and FileCollection.Add. The answers display both how to upload a file and how to modify its properties

asp.net Web API retrieve file(s) without saving them

I want to retrieve file(s) with ASP.NET Web Api, XML file(s) or zip file(s).
There are many examples how to do this, like this:
http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2
But the problem is, I don't want to save them on HDD!
I just want to validate the XML with some functions and generate a report on the fly and want to return this report.
But every tutorial use the "MultipartFormDataStreamProvider" witch save the files on HDD.
How can I get the file(s) and file name(s) in memory?
Kind regards
I think you can use the MultipartMemoryStreamProvider?
See a way to implement file upload without writing to the file system.

Export to PDF to a local folder

I have a Asp.net C# windows application where i call a SSRS Report.I want a functionality called " Export to pdf" in my page,and the following pdf must save into a local folder.Is it possible through coding or some other way.
use WkHtml
or itextSharp for better performance in open source projects.
Yes, but if you are using SOAP to access the report server, you need to build it up yourself. If you are using the report viewer controls or URL access, this functionality should already exist.

How I can export a datatable to excel 2007 and pdf from asp.net?

I have to make reports with graphics in Excel and PDF from data in a database in an asp.net app.
I don't want to use com objects so I have been using Open Xml Sdk to build the excel file from a template file and redirect the response to the new file generated but I don't know how to make the PDF file...
I accept any comments about how I can generate the pdf file in my web app...
Thanks by the time invested reading this...
go to this site for pdf.
http://itextsharp.sourceforge.net/
I've done this before but with a bit of a cheat.
Office XP and onwards can actually read html files as office documents so if you sent a html document containing a table with the extension and mime type of an excel doc then windows would open it in excel.
From there you can use a web service such as http://www.htm2pdf.co.uk/htm2pdf-web-service.aspx to convert the html table data into a pdf.
Even better than that if you change the extension of a docx or xslx file to zip you can unzip the stored files and you'll find they are xml files that you can edit and rezip (changing the extension back of course).
The easiest solution -- in my opinion -- is to use Client Report Definition Files. After you defined reports, you can
show them to users in your ASP.NET application using the ReportViewer component (Google for asp.net ReportViewer),
export them directly to Excel (Google for localreport excel),
export them directly to PDF (Google for localreport pdf).
For the last two options, you can either save the file to disk or send it directly to the asp.net client (again, there are lots of code examples on the web).

Export into different file format

I want to Export in charts & datagrid data into different file formats - "PDF, Word and
Excel" in my web application..I am using Flex 3 and want to export the file in local system.
Any help will be highly appreciable...
Thanks in Advance...
If you are using Java/.NET/PHP or any back-end, you should be using PDF/word generation API to stream the file in required format.
For ex: You can use Apache POI or APache FOP apis to render MSword or PDF files and using Flex, users can download the files.
http://poi.apache.org/
xmlgraphics.apache.org/fop/
You can use AlivePDF to create PDF files in AS3.

Resources