Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 19th, 2004, 11:50 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
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.
Reply With Quote
  #2 (permalink)  
Old July 20th, 2004, 06:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
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.
Reply With Quote
  #3 (permalink)  
Old July 21st, 2004, 05:52 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
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;

Reply With Quote
  #4 (permalink)  
Old July 22nd, 2004, 05:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
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.
Reply With Quote
  #5 (permalink)  
Old July 26th, 2004, 06:07 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:30 AM.


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