31 个解决方案
#1
using System;
namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string filePath=@"C:\test.xls";
object missing=System.Reflection.Missing.Value;
Excel.ApplicationClass excelApp=new Excel.ApplicationClass();
Excel.Workbook workbook=excelApp.Workbooks.Open(filePath,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing);
excelApp.Visible=true;
}
}
}
namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string filePath=@"C:\test.xls";
object missing=System.Reflection.Missing.Value;
Excel.ApplicationClass excelApp=new Excel.ApplicationClass();
Excel.Workbook workbook=excelApp.Workbooks.Open(filePath,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing);
excelApp.Visible=true;
}
}
}
#2
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = @"c:\a.excel";
process.Start();
process.StartInfo.FileName = @"c:\a.excel";
process.Start();
#3
楼上的方法我试过了,没有打开Excel 只是在进程里面有,但没有显示
#4
点击一个按钮,然后打开excel
#5
asp.net在后台调用的excel是没有界面的.
#6
我需要打开excel 然后让用户可以打印
在前台可以实现吗?
在前台可以实现吗?
#7
前台那是客户端的事,你可以先让用户下载excel到本地,然后打开打印.
#8
不能直接打开吗
#9
下载的时候就可直接打开.
#10
谢谢幕白兄,不过我在打开的时候需要对excel的内容进行修改,有些内容要根据登陆的人不同,显示的内容不同
这种好象不行
这种好象不行
#11
页面已Excel格式打开,可以更改Excel打印的余白吗?
#12
关注
#13
自己顶一个
#14
接点分,
#15
#16
关注帮顶下.楼住抢银行后,分点
#17
学习中
#18
看来解决不了
明天结贴
明天结贴
#19
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
class TestLateBound:System.Windows.Forms.Form
{
private System.Windows.Forms.Button myButton;
public TestLateBound()
{
myButton=new Button();
myButton.Text="调用EXCEL";
myButton.Location=new System.Drawing.Point(100,100);
myButton.Click+=new System.EventHandler(TestBound);
Controls.Add(myButton);
Text="测试后期绑定 Excel Application";
}
public void TestBound(object sender,System.EventArgs ef)
{
Type myExcel;
myExcel=Type.GetTypeFromProgID("Excel.Application");
object objExcel;
objExcel=Activator.CreateInstance(myExcel);
object[] param=new object[1];
param[0]=true;
try
{
myExcel.InvokeMember("Visible",BindingFlags.SetProperty,null,objExcel,param); //和VC++中差不多,需要将参数封装为数组传入
}
catch (Exception e)
{
MessageBox.Show (e.ToString());
}
}
public void InitializeComponent()
{
myButton = new System.Windows.Forms.Button();
SuspendLayout();
//
// myButton
//
myButton.Location = new System.Drawing.Point(128, 72);
myButton.Name = "myButton";
myButton.TabIndex = 0;
myButton.Text = "button1";
myButton.Click += new System.EventHandler(myButton_Click);
//
// TestLateBound
//
AutoScaleBaseSize = new System.Drawing.Size(6,14);
ClientSize = new System.Drawing.Size(292,266);
Controls.Add(myButton);
Name = "TestLateBound";
Load+=new EventHandler(TestLateBound_Load);
ResumeLayout(false);
}
public static void Main()
{
Application.Run(new TestLateBound());
}
private void myButton_Click(object sender, System.EventArgs e)
{
}
private void TestLateBound_Load(object sender, System.EventArgs e)
{
}
}
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
class TestLateBound:System.Windows.Forms.Form
{
private System.Windows.Forms.Button myButton;
public TestLateBound()
{
myButton=new Button();
myButton.Text="调用EXCEL";
myButton.Location=new System.Drawing.Point(100,100);
myButton.Click+=new System.EventHandler(TestBound);
Controls.Add(myButton);
Text="测试后期绑定 Excel Application";
}
public void TestBound(object sender,System.EventArgs ef)
{
Type myExcel;
myExcel=Type.GetTypeFromProgID("Excel.Application");
object objExcel;
objExcel=Activator.CreateInstance(myExcel);
object[] param=new object[1];
param[0]=true;
try
{
myExcel.InvokeMember("Visible",BindingFlags.SetProperty,null,objExcel,param); //和VC++中差不多,需要将参数封装为数组传入
}
catch (Exception e)
{
MessageBox.Show (e.ToString());
}
}
public void InitializeComponent()
{
myButton = new System.Windows.Forms.Button();
SuspendLayout();
//
// myButton
//
myButton.Location = new System.Drawing.Point(128, 72);
myButton.Name = "myButton";
myButton.TabIndex = 0;
myButton.Text = "button1";
myButton.Click += new System.EventHandler(myButton_Click);
//
// TestLateBound
//
AutoScaleBaseSize = new System.Drawing.Size(6,14);
ClientSize = new System.Drawing.Size(292,266);
Controls.Add(myButton);
Name = "TestLateBound";
Load+=new EventHandler(TestLateBound_Load);
ResumeLayout(false);
}
public static void Main()
{
Application.Run(new TestLateBound());
}
private void myButton_Click(object sender, System.EventArgs e)
{
}
private void TestLateBound_Load(object sender, System.EventArgs e)
{
}
}
#20
不用那么麻烦
<script>
function OpenFile()
{
openDocObj = new ActiveXObject("SharePoint.OpenDocuments.2"); // 为了兼容Office XP,可以创建“SharePoint.OpenDocuments.1”
openDocObj.EditDocument("http://10.2.55.7/CreateWindowsUser/aaa/totalEnd.xls");
}
</script>
<input type=button value=打开Excel文件 onclick="OpenFile();">
<script>
function OpenFile()
{
openDocObj = new ActiveXObject("SharePoint.OpenDocuments.2"); // 为了兼容Office XP,可以创建“SharePoint.OpenDocuments.1”
openDocObj.EditDocument("http://10.2.55.7/CreateWindowsUser/aaa/totalEnd.xls");
}
</script>
<input type=button value=打开Excel文件 onclick="OpenFile();">
#21
把IP和文件路径换下,就OK了
用JS操作本地
用JS操作本地
#22
学习
顶
顶
#23
这个有点用
记下了
记下了
#24
还是没有打开真正的EXCEL
#25
不可能
你肯定是路径不对
别原样粘贴啊大哥
路径改改,我试过了
没问题的
你肯定是路径不对
别原样粘贴啊大哥
路径改改,我试过了
没问题的
#26
在本地是可以用Process 打开的,客户端不行,js还打不开execl,除非做个插件,把文件下到本地,然后插件调用execl打开文件。不知道vbscript行不行,我不懂
#27
js打不开Excel?????
谁说的啊大哥
我打开了已经,我不能胡说吧??
谁说的啊大哥
我打开了已经,我不能胡说吧??
#28
我还没那么笨,如何我的路径是D:\liu\Sample.xls 应该怎么写
#29
FileInfo DownloadFile = new FileInfo(FullFileName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer=false;
Response.ContentType="application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer=false;
Response.ContentType="application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
#30
FullFileName="D:\liu\Sample.xls"
#31
对了
目录得在你的虚拟路径下
而且,要有操作文件的权限
目录得在你的虚拟路径下
而且,要有操作文件的权限
#1
using System;
namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string filePath=@"C:\test.xls";
object missing=System.Reflection.Missing.Value;
Excel.ApplicationClass excelApp=new Excel.ApplicationClass();
Excel.Workbook workbook=excelApp.Workbooks.Open(filePath,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing);
excelApp.Visible=true;
}
}
}
namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string filePath=@"C:\test.xls";
object missing=System.Reflection.Missing.Value;
Excel.ApplicationClass excelApp=new Excel.ApplicationClass();
Excel.Workbook workbook=excelApp.Workbooks.Open(filePath,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing);
excelApp.Visible=true;
}
}
}
#2
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = @"c:\a.excel";
process.Start();
process.StartInfo.FileName = @"c:\a.excel";
process.Start();
#3
楼上的方法我试过了,没有打开Excel 只是在进程里面有,但没有显示
#4
点击一个按钮,然后打开excel
#5
asp.net在后台调用的excel是没有界面的.
#6
我需要打开excel 然后让用户可以打印
在前台可以实现吗?
在前台可以实现吗?
#7
前台那是客户端的事,你可以先让用户下载excel到本地,然后打开打印.
#8
不能直接打开吗
#9
下载的时候就可直接打开.
#10
谢谢幕白兄,不过我在打开的时候需要对excel的内容进行修改,有些内容要根据登陆的人不同,显示的内容不同
这种好象不行
这种好象不行
#11
页面已Excel格式打开,可以更改Excel打印的余白吗?
#12
关注
#13
自己顶一个
#14
接点分,
#15
#16
关注帮顶下.楼住抢银行后,分点
#17
学习中
#18
看来解决不了
明天结贴
明天结贴
#19
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
class TestLateBound:System.Windows.Forms.Form
{
private System.Windows.Forms.Button myButton;
public TestLateBound()
{
myButton=new Button();
myButton.Text="调用EXCEL";
myButton.Location=new System.Drawing.Point(100,100);
myButton.Click+=new System.EventHandler(TestBound);
Controls.Add(myButton);
Text="测试后期绑定 Excel Application";
}
public void TestBound(object sender,System.EventArgs ef)
{
Type myExcel;
myExcel=Type.GetTypeFromProgID("Excel.Application");
object objExcel;
objExcel=Activator.CreateInstance(myExcel);
object[] param=new object[1];
param[0]=true;
try
{
myExcel.InvokeMember("Visible",BindingFlags.SetProperty,null,objExcel,param); //和VC++中差不多,需要将参数封装为数组传入
}
catch (Exception e)
{
MessageBox.Show (e.ToString());
}
}
public void InitializeComponent()
{
myButton = new System.Windows.Forms.Button();
SuspendLayout();
//
// myButton
//
myButton.Location = new System.Drawing.Point(128, 72);
myButton.Name = "myButton";
myButton.TabIndex = 0;
myButton.Text = "button1";
myButton.Click += new System.EventHandler(myButton_Click);
//
// TestLateBound
//
AutoScaleBaseSize = new System.Drawing.Size(6,14);
ClientSize = new System.Drawing.Size(292,266);
Controls.Add(myButton);
Name = "TestLateBound";
Load+=new EventHandler(TestLateBound_Load);
ResumeLayout(false);
}
public static void Main()
{
Application.Run(new TestLateBound());
}
private void myButton_Click(object sender, System.EventArgs e)
{
}
private void TestLateBound_Load(object sender, System.EventArgs e)
{
}
}
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
class TestLateBound:System.Windows.Forms.Form
{
private System.Windows.Forms.Button myButton;
public TestLateBound()
{
myButton=new Button();
myButton.Text="调用EXCEL";
myButton.Location=new System.Drawing.Point(100,100);
myButton.Click+=new System.EventHandler(TestBound);
Controls.Add(myButton);
Text="测试后期绑定 Excel Application";
}
public void TestBound(object sender,System.EventArgs ef)
{
Type myExcel;
myExcel=Type.GetTypeFromProgID("Excel.Application");
object objExcel;
objExcel=Activator.CreateInstance(myExcel);
object[] param=new object[1];
param[0]=true;
try
{
myExcel.InvokeMember("Visible",BindingFlags.SetProperty,null,objExcel,param); //和VC++中差不多,需要将参数封装为数组传入
}
catch (Exception e)
{
MessageBox.Show (e.ToString());
}
}
public void InitializeComponent()
{
myButton = new System.Windows.Forms.Button();
SuspendLayout();
//
// myButton
//
myButton.Location = new System.Drawing.Point(128, 72);
myButton.Name = "myButton";
myButton.TabIndex = 0;
myButton.Text = "button1";
myButton.Click += new System.EventHandler(myButton_Click);
//
// TestLateBound
//
AutoScaleBaseSize = new System.Drawing.Size(6,14);
ClientSize = new System.Drawing.Size(292,266);
Controls.Add(myButton);
Name = "TestLateBound";
Load+=new EventHandler(TestLateBound_Load);
ResumeLayout(false);
}
public static void Main()
{
Application.Run(new TestLateBound());
}
private void myButton_Click(object sender, System.EventArgs e)
{
}
private void TestLateBound_Load(object sender, System.EventArgs e)
{
}
}
#20
不用那么麻烦
<script>
function OpenFile()
{
openDocObj = new ActiveXObject("SharePoint.OpenDocuments.2"); // 为了兼容Office XP,可以创建“SharePoint.OpenDocuments.1”
openDocObj.EditDocument("http://10.2.55.7/CreateWindowsUser/aaa/totalEnd.xls");
}
</script>
<input type=button value=打开Excel文件 onclick="OpenFile();">
<script>
function OpenFile()
{
openDocObj = new ActiveXObject("SharePoint.OpenDocuments.2"); // 为了兼容Office XP,可以创建“SharePoint.OpenDocuments.1”
openDocObj.EditDocument("http://10.2.55.7/CreateWindowsUser/aaa/totalEnd.xls");
}
</script>
<input type=button value=打开Excel文件 onclick="OpenFile();">
#21
把IP和文件路径换下,就OK了
用JS操作本地
用JS操作本地
#22
学习
顶
顶
#23
这个有点用
记下了
记下了
#24
还是没有打开真正的EXCEL
#25
不可能
你肯定是路径不对
别原样粘贴啊大哥
路径改改,我试过了
没问题的
你肯定是路径不对
别原样粘贴啊大哥
路径改改,我试过了
没问题的
#26
在本地是可以用Process 打开的,客户端不行,js还打不开execl,除非做个插件,把文件下到本地,然后插件调用execl打开文件。不知道vbscript行不行,我不懂
#27
js打不开Excel?????
谁说的啊大哥
我打开了已经,我不能胡说吧??
谁说的啊大哥
我打开了已经,我不能胡说吧??
#28
我还没那么笨,如何我的路径是D:\liu\Sample.xls 应该怎么写
#29
FileInfo DownloadFile = new FileInfo(FullFileName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer=false;
Response.ContentType="application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer=false;
Response.ContentType="application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
#30
FullFileName="D:\liu\Sample.xls"
#31
对了
目录得在你的虚拟路径下
而且,要有操作文件的权限
目录得在你的虚拟路径下
而且,要有操作文件的权限