Re: to XLS
- To: mathgroup at smc.vnet.net
- Subject: [mg62386] Re: to XLS
- From: Rolf.Mertig at gmail.com
- Date: Wed, 23 Nov 2005 01:12:04 -0500 (EST)
- References: <20051121114855.JTPP8508.eastrmmtao02.cox.net@[172.18.52.8]> <dluqgr$nlb$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, just use the underlying JExcelApi (see www.andykhan.com ). Then ModifySheetName["mydata.xls", {"newsheetname1", "bla"}] will do what you want. (* ***************************************************** *) Off[General::spell1]; ModifySheetNames[xlsfile_String,sheetnames:{__String}]:=ModifySheetNames[xlsfile,xlsfile,sheetnames]; ModifySheetNames[xlsfile_String, newxlsfile_String, sheetnames:{__String}] := Module[{ ljc=ToExpression["JLink`LoadJavaClass"],jn = ToExpression["JLink`JavaNew"],wb,sheets}, Needs["JLink`"]; ToExpression["JLink`InstallJava[]"]; ljc["jxl.Workbook"]; wb = Workbook`createWorkbook[FF=jn["java.io.File", newxlsfile], Workbook`getWorkbook[jn["java.io.File", xlsfile ]]]; sheets = wb[getSheets[]]; Do[sheets[[i]][setName[sheetnames[[i]]]], {i, Min[Length[sheets],Length[sheetnames]]}]; wb[write[]]; wb[close[]]; newxlsfile ]; (* ********************************************************* *) Regards, Rolf Mertig GluonVision Gmbh, Berlin