May 7

convert excel workbook farmat 晴

admin365 , 15:34 , Excel , 评论(0) , 引用(0) , 阅读(40) , Via 本站原创 | |



[转载]
Share this post :
#*translate document from first format to seconf format
function translate_from_firstformat_to_seconfformat([System.Io.FileInfo] $source_file)
{
$source_file_name = $source_file.FullName
$dest_file_name = create_destination_file_name($source_file)
write-host -Foregroundcolor red "Convertting from $source_file to $dest_file_name"
$destinationfile = $Excel.Workbooks.Open($source_file_name)
$destinationfile.SaveAs($dest_file_name, $saveFormat)

}

#*creat the destination document in the same fold use same filename
function create_destination_file_name([System.Io.FileInfo] $source_file)
{
$dest_file_name = $source_file.Name.Remove($source_file.Name.Length - $source_file.Extension.Length) + ".xlsx"
$dest_directory = $source_file.DirectoryName
$dest_file = join-path $dest_directory $dest_file_name


return $dest_file
}
#*input the directory that documents in there want to converting
$path = $args[0]
if ($args.Length -ne 1)
{
write-host "Usage: Reformat.ps1 <path to root directory of rtf files>"
exit 1
}
else
{
$Excel = new-object -com Excel.Application
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Excel.XlFileFormat], "xlOpenXMLWorkbook")
get-childitem -path $path -include *.xls -recurse | foreach-object -process { translate_from_firstformat_to_seconfformat $_ }
$Excel.Quit()
}

#* all the format
#*xlCurrentPlatformText
#*xlWorkbookNormal
#*xlSYLK
#*xlWKS
#*xlWK1
#*xlCSV
#*xlDBF2
#*xlDBF3
#*xlDIF
#*xlDBF4
#*xlWJ2WD1
#*xlWK3
#*xlExcel2
#*xlTemplate
#*xlTemplate8
#*xlAddIn8
#*xlAddIn
#*xlTextMac
#*xlTextWindows
#*xlTextMSDOS
#*xlCSVMac
#*xlCSVWindows
#*xlCSVMSDOS
#*xlIntlMacro
#*xlIntlAddIn
#*xlExcel2FarEast
#*xlWorks2FarEast
#*xlExcel3
#*xlWK1FMT
#*xlWK1ALL
#*xlWK3FM3
#*xlExcel4
#*xlWQ1
#*xlExcel4Workbook
#*xlTextPrinter
#*xlWK4
#*xlExcel7
#*xlExcel5
#*xlWJ3
#*xlWJ3FJ3
#*xlUnicodeText
#*xlExcel9795
#*xlHtml
#*xlWebArchive
#*xlXMLSpreadsheet
#*xlExcel12 (Excel Binary Workbook in 2007 with or without macro’s, xlsb)
#*xlOpenXMLWorkbook (without macro's in 2007, xlsx)
#*xlWorkbookDefault
#*xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007, xlsm)
#*xlOpenXMLTemplateMacroEnabled
#*xlOpenXMLTemplate
#*xlOpenXMLAddIn
#*xlExcel8 (97-2003 format in Excel 2007, xls)


[转载]原文链接: http://orca2007.spaces.live.com/Blog/cns!330865806FCE202!2611.entry

百度搜索:Excel
Google搜索:Excel
雅虎搜索:Excel
SOSO搜索:Excel



Tags:
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]