注册 登录
编程论坛 VFP论坛

请教关于VFP控制EXCEL的问题

fanjinyu9108 发布于 2025-05-08 18:28, 366 次点击
VFP控制EXCE,用VFP设置工作表保护,同时允许设置列格式和行格式,请问如何实现?
6 回复
#2
fanjinyu91082025-05-08 20:22
        oWorksheet.Protect("123456")
        AllowFormattingColumns=.T.
        AllowFormattingRows=.T.
我搜索的,但是不行,可以保护工作表,但是不能允许设置列格式和行格式
#3
schtg2025-05-09 11:52
这个应该是可以的哈,抽空看一下咯。
#4
fanjinyu91082025-05-09 20:27
弄好了,是问deepseek解决的代码如下:
      mymm=ALLTRIM(thisform.text1.Value)
        oWorksheet.Protect(;
        mymm,             ; && Password(空字符串表示无密码)
        .T.,           ; && DrawingObjects(允许修改图形)
        .T.,           ; && Contents(保护内容)
        .T.,           ; && Scenarios(保护方案)
        .F.,           ; && UserInterfaceOnly(False)
        .F.,           ; && AllowFormattingCells(设为.F.,因为单独控制行列格式)
        .T.,           ; && AllowFormattingColumns(允许列格式)
        .T.,           ; && AllowFormattingRows(允许行格式)
        .F.,           ; && AllowInsertingColumns(禁止插入列)
        .F.,           ; && AllowInsertingRows(禁止插入行)
        .F.,           ; && AllowDeletingColumns(禁止删除列)
        .F.,           ; && AllowDeletingRows(禁止删除行)
        .T.,           ; && AllowSorting(允许排序)
        .T.,           ; && AllowFiltering(允许筛选)
        .T.            ; && AllowUsingPivotTables(允许数据透视表)
         )
         &&限定结束
#5
hsfisher2025-05-16 17:38
借鉴学习
#6
wengjl2025-05-20 08:31
以下是引用fanjinyu9108在2025-5-9 20:27:57的发言:

弄好了,是问deepseek解决的代码如下:
      mymm=ALLTRIM(thisform.text1.Value)
        oWorksheet.Protect(;
        mymm,             ; && Password(空字符串表示无密码)
        .T.,           ; && DrawingObjects(允许修改图形)
        .T.,           ; && Contents(保护内容)
        .T.,           ; && Scenarios(保护方案)
        .F.,           ; && UserInterfaceOnly(False)
        .F.,           ; && AllowFormattingCells(设为.F.,因为单独控制行列格式)
        .T.,           ; && AllowFormattingColumns(允许列格式)
        .T.,           ; && AllowFormattingRows(允许行格式)
        .F.,           ; && AllowInsertingColumns(禁止插入列)
        .F.,           ; && AllowInsertingRows(禁止插入行)
        .F.,           ; && AllowDeletingColumns(禁止删除列)
        .F.,           ; && AllowDeletingRows(禁止删除行)
        .T.,           ; && AllowSorting(允许排序)
        .T.,           ; && AllowFiltering(允许筛选)
        .T.            ; && AllowUsingPivotTables(允许数据透视表)
         )
         &&限定结束


你是一个好同志,收藏学习,谢谢!
#7
girlsfriend2025-05-22 08:48
学习了
1