Exporting to Excel

Hi pals, I need some help…

anyone knows how to exporting the content of view to the Excel, I mean, not just click File–>Export, but to do it with the codes so client can just click it and an excel workbook will be generated into file…

thx…

Subject: Exporting to Excel

Put this code in the action button on the view

Dim WS As notesuiworkspace

Dim UiView As notesuiview

Dim ViewString As String

Dim session As NotesSession

Dim db As NotesDatabase 

Dim v As NotesView

Dim docX As NotesDocument

Dim col As Integer

Dim row As Double

Dim xl As Variant

Dim xlWbk As Variant

Dim pagename As String



Set WS = New notesuiworkspace

Set session = New notessession

Set db=session.CurrentDatabase



Print "Please Be Patient as the Excel Spreadsheet is being created..."

’ Get dynamic view name, R5 only

’ Take this part out if using in R4, you have to hard-code the name of the view in ViewString

Set v=db.GetView("Acc_Level_Report")

’ Create Excel Sheet

Set xl=CreateObject("Excel.Application")

xl.Visible=False

Set xlWbk=xl.Workbooks.Add

’ Add column headings to first row

col=1

Forall vColumn In v.Columns

	xlWbk.ActiveSheet.Cells(1, col)=vColumn.Title

	col=col+1

End Forall

’ Add row data from the documents

row=2

Set docX=v.GetFirstDocument

While Not docX Is Nothing

	col=1

	Forall cValue In docX.ColumnValues

		xlWbk.ActiveSheet.Cells(row, col)=cValue

		col=col+1

	End Forall

	row=row+1

	Set docX=v.GetNextDocument(docX)

Wend

’ Make all columns fit

xlWbk.ActiveSheet.Columns.AutoFit

xl.Rows("1:1").Select

xl.Selection.Font.Bold = True

xl.selection.Font.Name = "Arial"

xl.selection.Font.Size = 9

xl.selection.columns.Autofit

xl.referencestyle = 1

xl.Range("A1").Select



Print ""

xlWbk.close True

xl.quit

Set xl = Nothing

Set xlWbk = Nothing

Subject: RE: Exporting to Excel

Hi thx anyway for your help…I havent tried it yet, but I want to know…

Where you learn that codes…is it really yours or any tutorial about making something like that?

I dont mean to interupt you or anything negative, but here, I’m in development section, sometimes found it difficult to make some application because the lack of information I have(just like the one I’m asking, about exporting data to SQL, I’d searched it on Lotus domino help, but found nothing). So if you have some place to share, or any websites contains any help for domino designer, please let me know it…

Thx so muchh…/_/\

Subject: RE: Exporting to Excel

its a mix of both actllly… You can actlly form your code by simply searching for the API’s for anything… eg excel, MsGraph , word…etc… In API u get diff objects and handles to directly communicate and perfrom operations on non-lotus applicns from notes. Those functions u see in the Xl code to write data in an XL file wont be avail in the Notes Help. U will just have to see them in the XL API… … I hope this solves ur query.

Subject: This forum…

Also, if you’d have searched this forum in the first place you would have found 100s of examples of this exact type of code.

Also use the sandbox - there’s a link on the right of the page under resources, where there’s many code snippets, including exporting to and importing from excel.

Dan