易表在线答疑技术与交流应用技巧 → [原创]几个数据备份恢复的公式


  共有14216人关注过本帖平板打印复制链接

主题:[原创]几个数据备份恢复的公式

帅哥哟,离线,有人找我吗?
老宋
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:215 积分:148 威望:0 精华:0 注册:2007/7/18 15:48:00
[原创]几个数据备份恢复的公式  发帖心情 Post By:2009/9/13 10:41:00 [只看该作者]

[这个贴子最后由老宋在 2009/09/22 05:13pm 第 1 次编辑]

历经两个月的潜心易表研究,做了一个材料管理系统,同时做了几个通用的数据处理方面的公式,不敢独用,分享一下,希望能给大家带来一些帮助:
1.保存退出(自动备份超过500行数据的表)
Eval("If(["+Substitute(Substitute(Substitute(Substitute(Eval(Substitute("Substitute(#|@|$|&|#,#|#,#"+Substitute(ListGrids(),"|","#)+#|#+Substitute(#|@|$|&|#,#|#,#")+"#)","#","""")),"@","!Rows]>499,ExportTextFile(DocDir+"""),"$","""+"".txt"",char(9),Char(13),"""),"&",""",2) And ClearGrid("""),"|","""),True) And If([") + """),True)") And Save() And Exit()

2.数据加载(自动加载被清空的表的数据)
Eval("If(["+Substitute(Substitute(Substitute(Substitute(Eval(Substitute("Substitute(#|@|&|#,#|#,#"+Substitute(ListGrids(),"|","#)+#|#+Substitute(#|@|&|#,#|#,#")+"#)","#","""")),"@","!Rows]<2,SpenGrid("""),"&",""") And ImportTextFile(DocDir+"""),"|","""+"".txt"",Char(9),Char(13),0),True) And If(["),"Spen","Open")+ """+"".txt"",Char(9),Char(13),0),True)")


1.备份系统(自动备份所有表的数据)
Eval(Substitute("ExportTextFile(DocDir+#"+Eval("Substitute(""|#+#.txt#,char(9),Char(13),#|"",""|"","""+Substitute(ListGrids(),"|",""")+""#,3) And ExportTextFile(DocDir+#""+Substitute(""|#+#.txt#,char(9),Char(13),#|"",""|"",""")+""")")+"#,3)","#",""""))

2.恢复系统(自动加载所有表的数据)
Eval(Substitute(Substitute("SpenGrid(#"+Eval("Substitute(""|#) And ImportTextFile(DocDir+#|"",""|"","""+Substitute(ListGrids(),"|",""")+""#+#.txt#,Char(9),Char(13),0) And SpenGrid(#""+Substitute(""|#) And ImportTextFile(DocDir+#|"",""|"",""")+""")") + "#+#.txt#,Char(9),Char(13),0)","#",""""),"Spen","Open")) And Eval(Substitute("DelRow(#"+Substitute(ListGrids(),"|","#,1) And DelRow(#")+"#,1)","#",""""))
3.清空系统(自动清空所有表的数据)
Eval(Substitute("ClearGrid(#"+Substitute(ListGrids(),"|","#) And ClearGrid(#")+"#)","#",""""))

克隆表
SetVariable("%AAA%","材料台账") And SubtotalFill([%AAA%],"Substitute(ListCols([%AAA%]),""|"","","")","","") And ClearGrid(Grid) And OpenGrid([%AAA%]) And OpenGrid("万能报表")

以前的公式有太多的引号,套用函数后,将产生更多的引号,如果用#号将引号提前替换,套用函数将省去很多问题:

一翻二:
Eval(Substitute("Substitute(#|@|#,#|#,#"+Substitute(ListGrids(),"|","#)+#|#+Substitute(#|@|#,#|#,#")+"#)","#",""""))

一翻三:
Eval(Substitute("Substitute(#|@|&|#,#|#,#"+Substitute(ListGrids(),"|","#)+#|#+Substitute(#|@|&|#,#|#,#"


 回到顶部