Home > Domino Tips > Developer > LotusScript > Exporting and importing to and from Excel
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Exporting and importing to and from Excel


Forrest c. Gilmore
05.08.2002
Rating: -4.28- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


I find that the normal Notes export functions often are not adequate. Long text strings and formatted text often do not work. The same hold true for importing data.

The solution to all of these problems is to use Excel. Scripts have been written to use Excel for supporting this functionality.

Code

Some limitations of the export to 1-2-3 can be overcome by supplying a WK4 extension, but the 254-character cell limitation still exists, I believe.

There is a capability provided by Microsoft to add Excel option to the import/export options in Notes, but IBM does not support this "feature."

See Technote #164273 on the IBM Notes Technical Support Site.

D. Hasa has published a free script (ExportToExcel-Script v2) that can be used to export documents to Excel. Go to http://www-10.lotus.com/ldd/sandbox.nsf/85d5b6903071400e8525676d0079b3ae/e2a31b9d2a77f41685256b260050b64d?OpenDocument

The following is an example of a script to import an XLS file into Notes from a view:

Sub Click(Source As Button)
'The action button is located on a view named Import1
 Dim ws As New NotesUIWorkspace
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Set db = session.CurrentDatabase
 Dim view As NotesView
 Dim doc As NotesDocument
 Dim temp1 As String
 Dim temp2 As String
 Dim temp3 As String
 Dim temp4 As String
 Dim temp5 As String
 Dim temp6 As String
 Dim xlApp As Variant
 Dim xlSheet As Variant
 Dim cursor As Integer
 Dim recordcheck As String
 
 On Error Goto ERRORLABEL
 Dim FileName As String
 Dim DefaultFileName As String
 DefaultFileName="c:tempsheet.xls"
 
 NamePrompt$="Enter the complete Path and File Name of the Excel 
file to be imported:" &Chr(13) FileName=Inputbox(NamePrompt$,"Import File Name
Specification",DefaultFileName,100,100) If FileName="" Then Goto SubEnd 'Create an Excel object for the spreadsheet 'It may be necessary to have the proper MS Office DLLs installed
on the PC running this application 'That is, the person must be able to open the XLS file with Excel Set xlApp = CreateObject("Excel.Application") xlApp.Application.Workbooks.Open Filename
'File not found will return ERR=213 and the routine will be ended With xlApp.workbooks.Add 'Not sure what this line is for, unless it's to be sure that at
least one workbook is present in the XLS file End With 'Stop Set xlSheet = xlApp.Workbooks(1).Worksheets(1) recordcheck="x" r=1 ' Row counter - first row contains fieldnames from the database; 'these fieldnames are not needed as long as the spreadsheet follows a specified format While recordcheck <>"0" And recordcheck <> "" And r<100 'Recordcheck = "0" when there is no value in the first cell of the row,
if integer, or "", if string 'Important - Set r to a value that will stop the import routine without
missing any data, if the other criteria do not 'For this example, six columns are imported cursor=0 r=r+1 temp1=xlSheet.Cells(r,1).value recordcheck=Cstr(temp1) If recordcheck="0" Then Goto Finished ' Avoid generating empty record temp2=xlSheet.Cells(r,2).value temp3=xlSheet.Cells(r,3).value temp4=xlSheet.Cells(r,4).value temp5=xlSheet.Cells(r,5).value temp6=xlSheet.Cells(r,6).value 'The above lines lines could be combined with those below, but keep
separate for ease in debugging until ready to finalize the code Set doc = New NotesDocument(db) doc.Form = "frmName" doc.Field1 = temp1 doc.Field2 = temp2 doc.Field3= temp3 doc.Field4 = temp4 doc.field5 = temp5 doc.field6 = temp6 Call Doc.Save(True, False) Finished: Wend Goto SubClose ERRORLABEL: 'Msgbox "An error was encountered." 'Print "Error: " Error(), " Err:" Err(), " Erl:" Erl() If Err=213 Then Messagebox Filename & " was not found. Verify Path and Filename, then try the Import again." Resume SubEnd Else Messagebox "Error" & Str(Err) & ": " & Error$ End If Resume Next SubClose: xlApp.activeworkbook.close xlApp.Quit Set xlapp = Nothing Set view=db.getview("import1") Call ws.viewrefresh SubEnd: End Sub

Hopefully, IBM will add Excel Import/Export options by default, since 1-2-3 is no longer being upgraded, and current version have serious limitations.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
LotusScript
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication
LotusScript filters and attaches files to a Notes form

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts