Jump to content

Export cad text/ table in excel (get Error)


Ish

Recommended Posts

What do you get with TABLEEXPORT command... You could specify file format of export as *.csv (it must not always be native *.xls or *.xlsx)...

Link to comment
Share on other sites

Ok if its actually column of text then need something like pick column of text I have it somewhere trying to find. It sorts the selected text based on y value. Can have multiple columns.

 

Needs a rewrite original 2004.

 

 

  • Like 1
Link to comment
Share on other sites

10 hours ago, devitg said:

The main fact is that is not any ACADTABLE . it are lines and text arranged like a TABLE, but not an ACADTABLE 

what will be the solution. Sir?

 

Link to comment
Share on other sites

4 hours ago, hosneyalaa said:

 I GOT BELOW ERROR.

AFTER APPLOAD THE LISP. I GOT THE BELOW ERROR.

------------------------------------------------------------------------------------------------------

Command: AP
APPLOAD Export-Table Text-to-Excel.lsp successfully loaded.


Command:
Exportý Autocad Drawn Table to Excel
©2014

Averbuh Igal Software
type 'tbltoex' to execute.; error: Automation Error. Add method of Workbooks class failed

 

 

 

Link to comment
Share on other sites

Export-Table Text-to-Excel.lsp 

THIS IS GOOD FOR ME BETTER THAN COT LISP,

ANY POSSIBILITIES TO SOLVE BELOW ERROR SIR. 

type 'tbltoex' to execute.; error: Automation Error. Add method of Workbooks class failed.

MY AUTOCAD 2020.

 

THANKS

Link to comment
Share on other sites

15 hours ago, Ish said:

Export-Table Text-to-Excel.lsp 

THIS IS GOOD FOR ME BETTER THAN COT LISP,

ANY POSSIBILITIES TO SOLVE BELOW ERROR SIR. 

type 'tbltoex' to execute.; error: Automation Error. Add method of Workbooks class failed.

MY AUTOCAD 2020.

 

THANKS

 

 

If the error persists, or try this shorter routine as an alternative without using COM API.

Its just a simpler algorithm merely sorting each row of TEXT from top to bottom.

since it does not collect line coordinates and the output just a normal 'csv' file, so don't expect auto cell formatting, column size, alignment etc..  

however you still can format cell easily in EXCEL sheet & rename as .xls.

 

 

(defun c:tt (/ *error* foo ss fn f a b l ls l1 lst) ;hanhphuc 28.10.2019
  
  (defun *error* (msg)
    (if (and f (= (type f) 'FILE))
      (close f)
      (setq f nil)
      )
    )
  
  (and (setq foo '((a b) (cdr (assoc a (entget b)))) 
             ss  (ssget '((0 . "TEXT") (8 . "Text")))
             )
       (setq l (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) ; (acet-ss-to-list ss)
       (setq fuzz (* 0.25 (foo 40 (car l)))
             ls   (mapcar ''((x) (cons (foo 1 x) (foo 10 x))) l)
             )
       (setq fn (vl-filename-mktemp "table.csv") )
       (setq f (open fn "w"))
       (setq l  nil
             sl (vl-sort ls
                         ''((a b)
                            (if
                             (equal (caddr a) (caddr b) fuzz)
                             (< (cadr a) (cadr b))
                             (< (caddr a) (caddr b))
                             )
                            )
                         )

             a  (caddar sl)
             )

       (foreach x sl
         (if (equal a (setq b (caddr x)) fuzz)
           (setq l1 (cons x l1)
                 a  b
                 )
           (setq l1 (vl-list* x nil l1))
           )
         (setq a b)
         ) ;_ end of foreach
       (foreach x (progn (foreach x l1
                           (if x
                             (setq l (cons x l))
                             (setq lst (cons l lst)
                                   l   nil
                                   )
                             )
                           )
                         (setq lst (cons l lst))
                         (reverse (vl-remove nil lst))
                         ) ; progn
         (write-line (apply 'strcat (mapcar ''((x) (strcat x ",")) (mapcar 'car x))) f)
         )
       (progn (if f
                (close f)
                )
              (vl-cmdf "start" fn) ; or (vl-cmdf "shell" fn) doesn't work if same filename opened i.e:locked for editting
              ;(startapp "notepad" fn) ; recommand to use this for mutiple files
              )
       ) ;and
  (princ)
  )

(or
  (wcmatch (strcase (getvar 'dwgname)) "*COORDINATE TABLE 1*")
  (alert
    "\nThis routine only tested in 'COORDINATE TABLE 1.dwg',
    \nPlease download at \nhttps://www.cadtutor.net/forum/topic/68979-export-cad-text-table-in-excel-get-error/"
    )
  )
(princ)

 

p/s: In case you have any blank cell in Table,  just replace it with "-" or any TEXT!

i.e. TEXT in each Cell in a Row must have content & aligned horizontally in WCS, otherwise texts merge from first column to next

Edited by hanhphuc
vl-filename-mktemp "table.csv"
  • Like 2
Link to comment
Share on other sites

2 hours ago, hanhphuc said:

 

 

If the error persists, or try this shorter routine as an alternative without using COM API.

Its just a simpler algorithm merely sorting each row of TEXT from top to bottom.

since it does not collect line coordinates and the output just a normal 'csv' file, so don't expect auto cell formatting, column size, alignment etc..  

however you still can format cell easily in EXCEL sheet & rename as .xls.

 

 


(defun c:tt (/ *error* foo ss fn f a b l ls l1 lst) ;hanhphuc 28.10.2019
  
  (defun *error* (msg)
    (if (and f (= (type f) 'FILE))
      (close f)
      (setq f nil)
      )
    )
  
  (and (setq foo '((a b) (cdr (assoc a (entget b)))) 
             ss  (ssget '((0 . "TEXT") (8 . "Text")))
             )
       (setq l (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) ; (acet-ss-to-list ss)
       (setq fuzz (* 0.25 (foo 40 (car l)))
             ls   (mapcar ''((x) (cons (foo 1 x) (foo 10 x))) l)
             )
       (setq fn (vl-filename-mktemp "table.csv") )
       (setq f (open fn "w"))
       (setq l  nil
             sl (vl-sort ls
                         ''((a b)
                            (if
                             (equal (caddr a) (caddr b) fuzz)
                             (< (cadr a) (cadr b))
                             (< (caddr a) (caddr b))
                             )
                            )
                         )

             a  (caddar sl)
             )

       (foreach x sl
         (if (equal a (setq b (caddr x)) fuzz)
           (setq l1 (cons x l1)
                 a  b
                 )
           (setq l1 (vl-list* x nil l1))
           )
         (setq a b)
         ) ;_ end of foreach
       (foreach x (progn (foreach x l1
                           (if x
                             (setq l (cons x l))
                             (setq lst (cons l lst)
                                   l   nil
                                   )
                             )
                           )
                         (setq lst (cons l lst))
                         (reverse (vl-remove nil lst))
                         ) ; progn
         (write-line (apply 'strcat (mapcar ''((x) (strcat x ",")) (mapcar 'car x))) f)
         )
       (progn (if f
                (close f)
                )
              (vl-cmdf "start" fn) ; or (vl-cmdf "shell" fn) doesn't work if same filename opened i.e:locked for editting
              ;(startapp "notepad" fn) ; recommand to use this for mutiple files
              )
       ) ;and
  (princ)
  )

(or
  (wcmatch (strcase (getvar 'dwgname)) "*COORDINATE TABLE 1*")
  (alert
    "\nThis routine only tested in 'COORDINATE TABLE 1.dwg',
    \nPlease download at \nhttps://www.cadtutor.net/forum/topic/68979-export-cad-text-table-in-excel-get-error/"
    )
  )
(princ)

 

p/s: In case you have any blank cell in Table,  just replace it with "-" or any TEXT!

i.e. TEXT in each Cell in a Row must have content & aligned horizontally in WCS, otherwise texts merge from first column to next

THANKS SIR, WORKING NICELY.

THANK YOU

Link to comment
Share on other sites

6 hours ago, BIGAL said:

Works 2020 very impressed ! 

 

NOW FOR ME I ALSO WORKING  Export-Table Text-to-Excel.lsp PERFECTLY.

THANKS ALL 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...