[rdnzl-cvs] CVS RDNZL/examples
eweitz
eweitz at common-lisp.net
Fri Aug 25 09:45:28 UTC 2006
Update of /project/rdnzl/cvsroot/RDNZL/examples
In directory clnet:/tmp/cvs-serv12875/examples
Added Files:
example.xls excel.lisp
Log Message:
sync with 0.10.3
--- /project/rdnzl/cvsroot/RDNZL/examples/example.xls 2006/08/25 09:45:28 NONE
+++ /project/rdnzl/cvsroot/RDNZL/examples/example.xls 2006/08/25 09:45:28 1.1
ÐÏࡱá > þÿ þÿÿÿ þÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ aÍÉÀ á °Á â \ p Edi Weitz B °a À = ¯ ¼ = x x ;T$8 X@ " · Ú 1 È ÿ A r i a l 1 È ÿ A r i a l 1 È ÿ A r i a l 1 È ÿ A r i a l "$"#,##0_);\("$"#,##0\)! "$"#,##0_);[Red]\("$"#,##0\)" "$"#,##0.00_);\("$"#,##0.00\)' " "$"#,##0.00_);[Red]\("$"#,##0.00\)7 * 2 _("$"* #,##0_);_("$"* \(#,##0\);_("$"* "-"_);_(@_). ) ) _(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)? , : _("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)6 + 1 _(* #,##0.00_);_(* \(#,##0.00\);_(* "-"??_);_(@_)à õÿ À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à õÿ ô À à À à + õÿ ø À à ) õÿ ø À à , õÿ ø À à * õÿ ø À à õÿ ø À ÿ ÿ ÿ ÿ ÿ ÿ`
4 Sheet1
G Sheet2
N Sheet3 Á Á 8 ü } Superhero Last name
First name Kent Clark Superman Wayne Bruce Batman Parker Peter Spidermanÿ Û [ c c b
aÍÉÀ ð
d ü©ñÒMbP?_ * + % ÿ Á ¡ " ÿ à? à? U ÿ ÿ ÿ ÿ ý
ý
ý
ý
ý
ý
ý
ý
ý
ý
ý
ý
× ø < * * * > ¶ @ ï 7
aÍÉÀ ÿ
d ü©ñÒMbP?_ * + % ÿ Á ¡ " ÿ à? à? U > ¶ @ ï 7
aÍÉÀ
d ü©ñÒMbP?_ * + % ÿ Á ¡ " ÿ à? à? U > ¶ @ ï 7
þÿ à
òùOh« +'³Ù0 @ H T h
ä Edi Weitz Microsoft Excel @ ø(º»@ Q=ÈÆ þÿ ÕÍÕ. +,ù®0 Ø P X d l t |
µ ä d Sheet1 Sheet2 Sheet3 Worksheets þÿÿÿ
þÿÿÿ þÿÿÿýÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿR o o t E n t r y ÿÿÿÿÿÿÿÿ À F @ù'ÈÆþÿÿÿ W o r k b o o k ÿÿÿÿÿÿÿÿÿÿÿÿ S u m m a r y I n f o r m a t i o n ( ÿÿÿÿ D o c u m e n t S u m m a r y I n f o r m a t i o n 8 ÿÿÿÿÿÿÿÿÿÿÿÿ --- /project/rdnzl/cvsroot/RDNZL/examples/excel.lisp 2006/08/25 09:45:28 NONE
+++ /project/rdnzl/cvsroot/RDNZL/examples/excel.lisp 2006/08/25 09:45:28 1.1
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*-
;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/excel.lisp,v 1.1 2006/08/25 09:45:28 eweitz Exp $
;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved.
;;; Redistribution and use in source and binary forms, with or without
;;; modification, are permitted provided that the following conditions
;;; are met:
;;; * Redistributions of source code must retain the above copyright
;;; notice, this list of conditions and the following disclaimer.
;;; * Redistributions in binary form must reproduce the above
;;; copyright notice, this list of conditions and the following
;;; disclaimer in the documentation and/or other materials
;;; provided with the distribution.
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;; This example is an adapted version of the code found at
;;; <http://www.c-sharpcorner.com/winforms/ExcelReadMG.asp>.
;;; It was tested with Microsoft Office 2003.
(in-package :rdnzl-user)
(enable-rdnzl-syntax)
(import-types "System.Windows.Forms" "DialogResult" "OpenFileDialog")
(import-types "Microsoft.Office.Interop.Excel" "ApplicationClass" "WorkbookClass" "Worksheet")
(use-namespace "Microsoft.Office.Interop.Excel")
(use-namespace "System.Windows.Forms")
(defconstant +missing+ [$System.Reflection.Missing.Value]
"Represents missing arguments.")
(defconstant +dialog-ok+ [$DialogResult.OK]
"Returned by `OpenFileDialog' if the user confirmed the dialog.")
(defconstant +initial-directory+
(load-time-value
(namestring (make-pathname :name nil :type nil
:defaults +pathname-defaults+))))
(defconstant +initial-filename+
(load-time-value
(namestring (make-pathname :name "example" :type "xls"
:defaults +pathname-defaults+))))
(defun prompt-for-file (title)
(let ((dialog (new "OpenFileDialog")))
(setf [%InitialDirectory dialog] +initial-directory+
[%Filter dialog]
"Microsoft Excel files (*.xls)|*.xls|All files (*.*)|*.*"
[%FileName dialog]
+initial-filename+
[%Title dialog] title)
(and [Equals [ShowDialog dialog] +dialog-ok+]
[%FileName dialog])))
(defun get-excel-range (file-name range)
(let* ((app (new "ApplicationClass"))
(workbooks [%Workbooks app])
(workbook (cast [Open workbooks file-name
+missing+ nil +missing+
+missing+ +missing+ +missing+
+missing+ +missing+ +missing+
+missing+ +missing+ +missing+
+missing+ +missing+]
"WorkbookClass"))
(worksheets [%Worksheets workbook])
(sheet (cast [get_Item worksheets 1] "Worksheet"))
(range [get_Range sheet range +missing+]))
(prog1 (cast [%Value2 [%Cells range]] "System.Array")
[Quit app])))
(defun convert-range-array-to-lists (range-array)
(loop for row from 1 to [GetLength range-array 0]
collect (loop for col from 1 to [GetLength range-array 1]
collect [ToString (aref* range-array row col)])))
(defun range-contents (&key (file-name (prompt-for-file "Select an Excel file"))
(range "A1:C4"))
(convert-range-array-to-lists
(get-excel-range file-name range)))
(disable-rdnzl-syntax)
More information about the Rdnzl-cvs
mailing list