日期:2014-05-19  浏览次数:20474 次

程序对excel的操作问题
我想在程序中对excel表的样式进行操作,如合并单元格,设置单元格背景色等
不知道各位有没有做过类似的,望高手赐教

------解决方案--------------------
感觉很难 up
------解决方案--------------------
这个比较简单了,你录制一个宏,根据里面的属性操作就可以了,只不过,命名空间要重新整理而已
------解决方案--------------------
VB中做過﹐C#的和asp.net沒有操作過樣式這些﹗
------解决方案--------------------
帮助UP,感觉可以先生成服务器端TABLE,
然后用table直接生成EXCEL,这样可行否?
------解决方案--------------------
owc操作.
------解决方案--------------------
using Microsoft.Office.Interop.Excel;

protected void Button1_Click(object sender, EventArgs e)
{
ApplicationClass oExcel = new ApplicationClass();
Workbook oBook;
Worksheet oSheet;
Range oRange;

string path = Server.MapPath( "../../documents/test.xls ");
oBook = oExcel.Workbooks.Open(path, 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);
oSheet = (Worksheet)oBook.Worksheets[1];

oRange = oSheet.get_Range( "A1 ", "C3 ");
oRange.Value2 = "test ";
oRange.Merge(false);

oExcel.DisplayAlerts = false;
oBook.Save();
oExcel.Quit();
}
------解决方案--------------------
http://www.microsoft.com/china/msdn/library/office/office/UndstaExcelObjModNETDev.mspx?mfr=true