找回密码
 立即注册

QQ登录

只需一步,快速开始

bingdaoice

中级会员

44

主题

208

帖子

608

积分

中级会员

积分
608
bingdaoice
中级会员   /  发表于:2020-7-9 15:39  /   查看:3922  /  回复:8
1金币

使用Spread的Save保存之后再打开,富文本格式消失。
使用了两种保存方法,再次打开,富文本格式均消失。
                System.IO.MemoryStream stream = new System.IO.MemoryStream();
                Spread_Excel.Save(AppEnvironment.Config.CertifWorkPath + Spread_Excel.Tag.ToString() + "-2.xml", false);
                Spread_Excel.Save(stream, true);


image.png837729186.png

image.png824435729.png

最佳答案

查看完整内容

问题的原因是"原始记录模板.xml"中,spread中的LegacyBehaviors设置为了None,将这个改成All后保存xml,再去加载即可

8 个回复

倒序浏览
最佳答案
最佳答案
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-7-9 15:39:35
来自 6#
本帖最后由 Richard.Ma 于 2020-7-10 17:29 编辑

问题的原因是"原始记录模板.xml"中,spread中的LegacyBehaviors设置为了None,将这个改成All后保存xml,再去加载即可

image.png326474913.png

回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-7-9 16:06:51
2#
你好,可以尝试修改为以下代码,测试可以保存上下标
  1.             fpSpread1.Sheets[0].Save(@"D:\Projects\test.xml", SaveXMLOptions.AllAndStyleMerging);
复制代码
回复 使用道具 举报
bingdaoice
中级会员   /  发表于:2020-7-9 16:13:34
3#
本帖最后由 bingdaoice 于 2020-7-9 16:15 编辑

使用   fpSpread2.Save(AppDomain.CurrentDomain.BaseDirectory + "111.xml", FarPoint.Win.Spread.SaveXMLOptions.AllAndStyleMerging);测试这后,格式依然没有保存下来。附件有DEMO,可重现此问题。

image.png681712340.png


spread_Save之后富文本格式消失.rar

14.35 MB, 下载次数: 116

回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-7-9 17:34:22
4#
测试发现你提供的这个xml文件本身有点问题,在设计器中和控件中富文本表现的本身就不一致
在控件中中有上下标但是在设计器中么有
在设计器中修改为有上下标保存退出后,在控件中又没有 ,这个还需要排查一下原因
回复 使用道具 举报
bingdaoice
中级会员   /  发表于:2020-7-10 09:21:57
5#
这个问题很重要,请版主务必帮我解决一下。
关系到项目的进展了。
回复 使用道具 举报
bingdaoice
中级会员   /  发表于:2020-7-13 14:40:51
7#
已修改,富文本可以正常显示了。
但新的问题出来了。我以前没有设置这个做的模板。画的表格线比较细。现在的边框线条都变了。而且线条粗细不同。
image.png980120239.png
回复 使用道具 举报
bingdaoice
中级会员   /  发表于:2020-7-13 16:25:59
8#
我目前使用了:            Spread_RecdCertif.LegacyBehaviors = LegacyBehaviors.Style;这种方式 查看以前制做的模板,表格线和以前一样了。
富文本也能正常的保存并显示。

但是我想请问一下版主:           LegacyBehaviors 的这么多种方式。分别是什么意思。有什么变化?我现在使用的LegacyBehaviors.Style这种方式,是个什么情况?
会对我以前制做的模板产生什么影响吗?
我们会制做很多模板。目前已制了几百个了。
以后全线启动的话会制做几千个模板。如果做好了之后,又要改模板的话,那用户意见就大了。

        //
        // 摘要:
        //     New behaviors will be applied automatically in new releases.
        None = 0,
        //
        // 摘要:
        //     All style default settings and behaviors will be compatible with previous version.
        //
        // 备注:
        //     Turn off this option to use new style system which is compatible with Excel.
        Style = 1,
        //
        // 摘要:
        //     Row height won't be auto adjusted when cell's value or properties are changed
        //     on UI of Spread, all auto fit row height will be treated as custom row height
        AutoRowHeight = 2,
        //
        // 摘要:
        //     Fallbacks to old behaviors of calculation engine.
        CalculationEngine = 4,
        //
        // 摘要:
        //     Initialized values of some properties will be different compared with previous
        //     versions.
        //
        // 备注:
        //     If this flag is turned off:
        //     FarPoint.Win.Spread.FpSpread.AllowUserFormulas is true.
        //     FarPoint.Win.Spread.FpSpread.AllowDragDrop is true.
        //     FarPoint.Win.Spread.FpSpread.AllowDragFill is true.
        //     FarPoint.Win.Spread.FpSpread.AllowSheetMove is true.
        //     FarPoint.Win.Spread.FpSpread.AllowEditOverflow is true.
        //     FarPoint.Win.Spread.FpSpread.BorderCollapse is FarPoint.Win.Spread.BorderCollapse.Collapse.
        //     FarPoint.Win.Spread.FpSpread.ResizeZeroIndicator is true.
        //     FarPoint.Win.Spread.FpSpread.TabStripPolicy is FarPoint.Win.Spread.TabStripPolicy.Always.
        //     FarPoint.Win.Spread.SheetView.SelectionPolicy is FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange.
        //     FarPoint.Win.Spread.SheetView.AutoFilterMode is FarPoint.Win.Spread.AutoFilterMode.EnhancedContextMenu.
        //     Changes for keys:
        //     - F2 start editing with current cell value.
        //     - Backspace start editing with empty editor.
        //     - F4 takes no effect.
        //     - When user press an input key to start editing, the current cell value will
        //     be replaced by the pressed key.
        //     The changed properties may be added more in the future release.
        PropertyDefaults = 8,
        //
        // 摘要:
        //     Initialized values of sheetview's Protect and cell's lock will be different compared
        //     with previous versions.
        Protect = 16,
        //
        // 摘要:
        //     All behaviors are compatible with previous version.
        All = 31,
        //
        // 摘要:
        //     Any attempt to set a value to a cell that contains a formula to fail and instead
        //     raise the FarPoint.Win.Spread.FpSpread.Error event.
        KeepFormulaOnSetValue = 32,
        //
        // 摘要:
        //     The cell text will be exported if there is an explicit cell type.
        //
        // 备注:
        //     This option doesn't affects to numeric, System.DateTime and System.TimeSpan values.
        PreferTextOnExport = 64
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-7-13 16:58:26
9#
LegacyBehaviors 本身就是提供向后兼容性,这里是一些介绍,理论上来说你之前的表格如果是老板做的,启用LegacyBehaviors 中的选项,可以获取更好的兼容性,减少错误

https://www.grapecity.com/spread ... =legacybehaviors%2C

https://www.grapecity.com/blogs/ ... wards-compatibility
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部