还是那个内嵌excel的保存的新的问题
上一贴,从excel文件里找到保存按钮,是可以保存数据了。现在我在窗体上,新建一个按钮,清除数据后保存,就不行了。麻烦高手帮我看一下。谢谢!import com;
import com.excel;
import win.ui;
/*DSG{{*/
mainForm = win.form(text="dsoFrame控件测试";right=1191;bottom=769;bgcolor=16448250)
mainForm.add(
button={cls="button";text="清空数据";left=321;top=718;right=421;bottom=751;z=5};
chkMenubar={cls="checkbox";text="显示菜单栏";left=613;top=721;right=716;bottom=748;bgcolor=16448250;z=2};
chkTitlebar={cls="checkbox";text="显示标题栏";left=930;top=721;right=1033;bottom=748;bgcolor=16448250;z=4};
chkToolbars={cls="checkbox";text="显示工具条";left=771;top=721;right=874;bottom=748;bgcolor=16448250;z=3};
custom={cls="custom";text="自定义控件";left=1;top=7;right=1184;bottom=690;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;z=1}
)
/*}}*/
mainForm.show();
import com.dsoFramer;
var dsoFrame = com.dsoFramer(mainForm.custom)
dsoFrame.menubar = true //去掉菜单栏
dsoFrame.titlebar = false; //去掉标题栏
dsoFrame.toolbars = false; //去掉工具条
dsoFrame.borderStyle = 0; //去掉边框(默认值)
mainForm.chkToolbars.oncommand = function(id,event){
dsoFrame.toolbars = mainForm.chkToolbars.checked;
}
mainForm.chkTitlebar.oncommand = function(id,event){
dsoFrame.titlebar = mainForm.chkTitlebar.checked;
}
import fsys.dlg;
var path = "E:\\DIP目录.xlsx"
dsoFrame.openFile(path);
var excel = com.excel( true );
mainForm.button.oncommand = function(id,event){
book = com.GetObject("Excel.Application");
sheet1 = book.sheets("sheet1");
sheet1.UsedRange.clear()//清除表格中旧的数据
book.ActiveWorkbook.Save(); //保存更改
excel.Quit();
}
return win.loopMessage();
import win.ui;
/*DSG{{*/
var winform = win.form(text="ReoGrid";right=759;bottom=469)
winform.add(
button={cls="button";text="tab2-button";left=18;top=413;right=143;bottom=457;z=1}
)
/*}}*/
import dotNet.ReoGrid;
//创建控件
var grid = ReoGrid.ReoGridControl(winform);
//当前工作表
var sheet1 = grid.CurrentWorksheet;
//修改数据
sheet1.Cells["A1"].Data = "测试";
//直接显示 aardio 表(字符串数组)
sheet1["B2:D4"] ={
{ "测试", "测试2" },
{ "测试3", "测试4" },
};
//设置列数据,参数(行索引、列索引,数据),注意 .NET 起始下标为 0
sheet1.SetCellData(5, 2, "hello world");
//设置列数据
sheet1["B3:C5"] ={ { 'a', 'b', 'c' }, { 1, 2, 3 }, { 4, 5, 6 } };
//获取 Range(单元格集合) 对象
var range = sheet1.Ranges["D4:I4"];
//设置 Range 数据
range.Data = { "Product", "Unit Price", "Quantity", "Extended Price" };
//修改样式(背景颜色) ,参数必须是 ReoGrid.Graphics.SolidColor 对象
range.Style.BackColor = ReoGrid.Graphics.SolidColor.Orange
//高亮区域
sheet1.AddHighlightRange("B2:D4");
///自定义控件
var checkboxCell = ReoGrid.CellTypes.CheckBoxCell();
//响应事件,不用任何封装,aardio 自动支持。
checkboxCell.CheckChanged = function(send,event){
winform.msgbox(checkboxCell.IsChecked)
}
sheet1["B6"] = checkboxCell;
//保存文件
grid.Save("/test.xlsx");
winform.show();
win.loopMessage();
页:
[1]