Sub Click(Source As Button)
Set objServiceManager = CreateObject("com.sun.star.ServiceManager")
Set objCoreReflection = objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
Set StarDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
Set dispatcher = objServiceManager.createInstance("com.sun.star.frame.DispatchHelper")
Set teste = objServiceManager.createInstance("com.sun.star.table.TableColumn")
' Cria um novo documento do Calc
Dim args()
sUrl = "private:factory/scalc"
Set oDoc = StarDesktop.loadComponentFromURL(sUrl, "_blank", 0, args())
Set frame = oDoc.CurrentController.Frame
' obtém a primeira planilha no documento
Set oPlanilha = oDoc.getSheets().getByIndex(0)
'Montando os valores pré-definidos (TABELA) *Dados Fictícios
'LINHA
Set oCelula = oPlanilha.getCellByPosition(0, 0)
oCelula.setString("RELATÓRIO:")
Set oCelula = oPlanilha.getCellByPosition(1, 0)
oCelula.setString("Satisfeito")
Set oCelula = oPlanilha.getCellByPosition(2, 0)
oCelula.setString("Nem Satisfeito / Nem Insatisfeito")
Set oCelula = oPlanilha.getCellByPosition(3, 0)
oCelula.setString("Insatisfeito")
'COLUNA
Set oCelula = oPlanilha.getCellByPosition(0, 1)
oCelula.setString("Tempo de Resposta")
Set oCelula = oPlanilha.getCellByPosition(0, 2)
oCelula.setString("Conteúdo da Resposta")
Set oCelula = oPlanilha.getCellByPosition(0, 3)
oCelula.setString("Facilidade de Acesso ao Sistema")
'Valores internos na tabela
For i=1 To 3
Set oCelula = oPlanilha.getCellByPosition(1, i)
oCelula.setValue(i+2)
Set oCelula = oPlanilha.getCellByPosition(2, i)
oCelula.setValue(i+4)
Set oCelula = oPlanilha.getCellByPosition(3, i)
oCelula.setValue(i-1)
Next
'GRÁFICO
Set classSize = objCoreReflection.forName("com.sun.star.awt.Rectangle")
classSize.createObject aStruct
Set Rect = aStruct
Dim RangeAddress(0)
Set classSize = objCoreReflection.forName("com.sun.star.table.CellRangeAddress")
classSize.createObject aStruct
Set RangeAddress(0) = aStruct
Set Charts = oDoc.getSheets().getByIndex(0).Charts
Rect.X = 8000
Rect.Y = 1000
Rect.Width = 10000
Rect.Height = 7000
RangeAddress(0).Sheet = 0
RangeAddress(0).StartColumn = 0
RangeAddress(0).StartRow = 0
RangeAddress(0).EndColumn = 3
RangeAddress(0).EndRow = 3
Call Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
Set Chart = Charts.getByName("MyChart").embeddedObject
Set Chart.Diagram = Chart.createInstance("com.sun.star.chart.BarDiagram")
Chart.HasMainTitle = True
Chart.Title.String = "Title"
Chart.HasSubTitle = True
Chart.Subtitle.String = "Subtitle"
Chart.HasLegend = True
Chart.Legend.CharHeight = 7
Chart.Diagram.HasYAxisTitle = True
Chart.Diagram.YAxisTitle.String = "Total de Respostas"
End Sub
Nenhum comentário:
Postar um comentário