how can i open a excel inside a web browser?
You can't control and launch software on the client (browser) computer - why? Security.
If this was possible, hackers would have taken over all computers long ago...
Can you please explain exactly what you are trying to do? Instead of asking how to open excel from the browser, if you explain what you need to accomplish, perhaps we can come up with a better idea.
Open Excel file url in excel (from source, not downloaded copy)
No it is not possible for security reasons. All newer browsers (and I guess even the newer implementations of IE), don't allow file access to the local system. Internet Explorer is the only browser that supports opening files from locations, that are seen and treated as local ones.
You can open files from a Webdav Server, which is probably, why you can access files from your SharePoint, so you could try mapping that provider of your network drive as a Webdav Server.
Source: https://www.codeproject.com/Questions/1180249/Open-edit-save-excel-sheet-from-browser-using-java AND
Is there an Application URL Protocol for MS Word?
Excel File opening in browser not calling Excel
Your code doesn't create an Excel file, it creates a CSV file. The content type isn't Excel-specific either. A browser may decide that Excel is the appropriate application to open this text file or not.
Even if the browser selects Excel, opening the file may fail, eg if the client's locale uses ,
as a decimal separator. This is common in European countries. In this case Excel expect ;
as the field separator and may open the CSV as a single text block.
Instead of trying to trick the browser into opening a CSV in Excel, create a real Excel file using a library like EPPlus. EPPlus is available as a Nuget package so it's very easy to add it to your project.
The library's documentation contains an article on how to use it in Web applications. Once you remove the formatting code from the example, the code is very simple:
private void DumpExcel(DataTable tbl)
{
using (ExcelPackage pck = new ExcelPackage())
{
//Create the worksheet
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo");
//Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
ws.Cells["A1"].LoadFromDataTable(tbl, true);
//Write it back to the client
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment; filename=ExcelDemo.xlsx");
Response.BinaryWrite(pck.GetAsByteArray());
}
}
Excel files are compressed which means that sending the file to the client will be a lot faster, especially for large files
Open excel file through normal html link
HTTP is a stateless protocol. What that means for you is that when your users download a file from the intranet via http, they are downloading a copy, rather than the original. Any changes they make will only appear in their copy, and then you end up with loads of copies of the same workbook with different, possibly overlapping changes. You don't want that!
And also ... how are your users even going to upload their changes?
You need to create a shared folder on your network and put the workbook there. You can then use the file:///SERVER/PATH/FILE.xls
format in your <a />
links on your intranet to direct your user to the actual file on the server.
I would recommend you start by creating a simple html doc on your desktop to get familiar with the file:///
path format.
Eg
<html>
<head />
<body>
<a href="file:///SERVER/PATH/FILE.xls">Click</a>
<body>
<html>
save that in notepad and rename the extension from .txt
to .html
.
You can also type file:///
paths straight into windows explorer's address bar which allow for testing paths without resorting to the html document mentioned above.
UNFORTUNATELY! It seems that the browsers default behavior is to always download a link rather than open it (even if it is a local resource), so if you actually want to open it then you must resort to changing your browser intranet permissions to allow JS to access local resources, which then allows you to use the technique below.
This article (http://www.codeproject.com/Articles/113678/How-to-execute-a-Local-File-using-HTML-Application) uses
<script type="text/javascript" language="javascript">
function RunFile() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
}
</script>
to open notepad. You can use command line arguments with Excel.exe (https://support.office.com/en-za/article/Command-line-switches-for-Excel-321cf55a-ace4-40b3-9082-53bd4bc10725) to tell it what the file path is...
Excel.exe "C:\PATH\Excel.xls"
Related Topics
How to Make a Gap Between Two Div Within the Same Column
How to Resize Image in Bootstrap Carousel
How to Get Angular to Reload the Same Page But With a Different Argument
How to Make Custom Dots in Owl Carousel
How to Change Bootstrap 4 Drop-Down Colors
How to Center Text (Horizontally and Vertically) Inside a Div Block
How to Make an Element Width: 100% Minus Padding
Expand a Div to Fill the Remaining Width
Vertically Centering a Div Inside Another Div
Why Does HTML Think "Chucknorris" Is a Color
Using HTML Anchor Link #Id in Angular 6
How to Place Div in Top Right Hand Corner of Page
How to Give Multiple Conditions in *Ngif Statement in Angular 6
Removing Margin from Flex Items When They Wrap
Children Not Staying Inside Parent Divs
When Flexbox Items Wrap in Column Mode, Container Does Not Grow Its Width