Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 19th, 2004, 11:50 PM
Registered User
 
Join Date: Jul 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default JOOLE & Excel

Here we go -> hundred points to the person who can answer this one.
My program currently dumps data into excel and creates a chart. Now, for the hard part, how do i reposition that chart?
I'd even settle for code to cut and "paste-special" as a picture (even though this loses the link)...
Any ideas?

Cheers

Ken.
 
Old July 20th, 2004, 06:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

can you post some code, if you are using some kind of automation to Excel you should be able to move it.
 
Old July 21st, 2004, 05:52 PM
Registered User
 
Join Date: Jul 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the code in it's entirety ... Good luck.

// choose a section and export to Excel
// at nominated address

var nRow = 1
var nCol = 1
var oExcel = new JOOLEObject("Excel.Application");
var xlColumns = 2;

oWorkBook = oExcel.Workbooks.Add;

// copy the data to the clipboard - need to find results.
ActiveDocument.Sections["Sheet 1"].Copy();

oExcel.Sheets.Item(2).Cells.Item(nCol).Item(nRow). Select;
oExcel.Sheets.Item(2).Paste;

oExcel.Sheets.Item(2).Rows.Item(nRow).Font.Bold = true;
oExcel.Sheets.Item(2).Rows.Item(nRow).Interior.Col orIndex = 34;
oExcel.Sheets.Item(2).Columns.AutoFit;

//
// Setup Page for graphs
//

oExcel.Sheets.Item(1).Select;

oExcel.ActiveSheet.PageSetup.Orientation = 2;
oExcel.ActiveSheet.PageSetup.CenterHorizontally = true;
oExcel.ActiveSheet.PageSetup.LeftMargin = 0;
oExcel.ActiveSheet.PageSetup.RightMargin = 0;

// Set Columns
oExcel.Range("A:A").ColumnWidth = 69.57;
oExcel.Range("B:B").ColumnWidth = 2;
oExcel.Range("C:C").ColumnWidth = 69.57;

//
// Create Graph
//

oExcel.Sheets.Item(1).Select;
oExcel.Charts.Add;
oExcel.ActiveChart.ChartType = 52 //ColumnStacked

cRange = "A1:C238"
oExcel.ActiveChart.SetSourceData(2,oExcel.Sheets.I tem("Sheet 1").Range( cRange))
oExcel.ActiveChart.Location("Sheet 2",2);
oExcel.ActiveChart.HasTitle = 1;
oExcel.ActiveChart.ChartTitle.Characters.Text = "?"
oExcel.ActiveChart.ChartTitle.Font.bold = true;


// Alter Legend and plot area
oExcel.ActiveChart.Legend.Select;
oExcel.Selection.Left = 285
oExcel.Selection.Top = 2
oExcel.ActiveChart.PlotArea.Select;
oExcel.Selection.Top = 16
oExcel.Selection.Width = 354
oExcel.Selection.Height = 195

// Move chart to desired position -> here is the problem
oExcel.ActiveChart.ChartArea.Select;
oExcel.Selection.Left = 385
oExcel.Selection.Top = 40

// Have tried these as well - no luck
// oExcel.ActiveSheet.Shapes("Chart 1").ShapeRange.IncrementTop("50")
// oExcel.ActiveSheet.Shapes("Chart 1").IncrementTop = -67.5

//
// Finalise
//

oExcel.Visible = true;

 
Old July 22nd, 2004, 05:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

The code you have posted looks almost identical to the MS API for Excel - I guess this JOOLE stuff is just a wrapper for that - there is a working sample of similar code at http://www.greggriffiths.org/webdev/both/excel/ which has a link to the MS Excel API listings, where in you should find the functions you need to do this.
 
Old July 26th, 2004, 06:07 PM
Registered User
 
Join Date: Jul 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Greg

I've managed to find a solution :D(just for everyone's records) which is:

// Move chart up and to the left
oExcel.ActiveChart.Parent.Top=-50;
oExcel.ActiveChart.Parent.Left=-50;

The link you posted didn't provide any new information however ... bummer.
Cheers anyhow.
K.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel & RibbonX LBAKER Excel VBA 0 August 13th, 2008 11:25 AM
Excel VBA & SQL LouNeate Excel VBA 2 April 5th, 2007 01:28 PM
Excel 2002 Sp1 & Excel Sp2 anup.bihani Excel VBA 0 November 23rd, 2006 04:48 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.