你好,你所需要的题意:写入excel时候不用\n而是用tab对应的表达方式。
成果。
(defun c:Q2()
(setq ffn (getfiled "写出文件" "" "xls" 1))
(princ "\n选取文字...")
(setq ss (ssget))
(setq ff (open ffn "w"))
(setq i 0)
(repeat (sslength ss)
(setq ssn (ssname ss i))
(setq ssdata (entget ssn))
(setq sstyp (cdr (assoc 0 ssdata)))
(if (or (= sstyp "TEXT") (= sstyp "MTEXT"))
(progn
(setq txt (cdr (assoc 1 ssdata)))
(princ txt ff)
(princ (chr 9) ff)
)
)
(setq i (1+ i))
)
(close ff)
(princ (strcat "\n写出文件: " ffn))
(prin1)
)
就是将
(princ "\n" ff)
改为
(princ (chr 9) ff)
或者
(princ “\t” ff)
;;各种chr值详见百度。