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À=¯Œ=xx;T$8X@"·Ú1ÈÿArial1ÈÿArial1ÈÿArial1ÈÿArial"$"#,##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);_(* "-"??_);_(@_)àõÿ À àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ àõÿ ôÀ à À à+õÿ øÀ à)õÿ øÀ à,õÿ øÀ à*õÿ øÀ à õÿ øÀ ÿÿÿÿÿÿ` 4Sheet1 GSheet2 N Sheet3ÁÁ8ü} Superhero Last name First nameKentClarkSupermanWayneBruceBatmanParkerPeter SpidermanÿÛ[ccb aÍÉÀð dü©ñÒMbP?_*+%ÿÁ¡"ÿà?à?Uÿÿÿÿý ý ý ý ý ý ý ý ý ý ý ý ×ø<***>¶@ï7 aÍÉÀÿ dü©ñÒMbP?_*+%ÿÁ¡"ÿà?à?U>¶@ï7 aÍÉÀ
dü©ñÒMbP?_*+%ÿÁ¡"ÿà?à?U>¶@ï7 þÿà òùOh«+'³Ù0 @HTh äEdi WeitzMicrosoft Excel@ø(º»@Q=ÈÆþÿÕÍÕ.+,ù®0Ø PXdlt| µädSheet1Sheet2Sheet3Worksheetsþÿÿÿ þÿÿÿþÿÿÿýÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRoot Entryÿÿÿÿÿÿÿÿ ÀF@ù'ÈÆþÿÿÿWorkbookÿÿÿÿÿÿÿÿÿÿÿÿSummaryInformation(ÿÿÿÿDocumentSummaryInformation8ÿÿÿÿÿÿÿÿÿÿÿÿ--- /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)