Save Excel as a CSV format file

Source: Internet
Author: User

Save Excel directly as a CSV, fast:

$FilePath _public_ip_maps_infos="D:\My documents\work\ip Mapping table. xlsx"$Excel= New-object-Com Excel.Application$Excel. Visible =$False $Excel. displayalerts=$False $WorkBook=$Excel. Workbooks.Open ($FilePath _public_ip_maps_infos) #Save As CSV format, you need to set the parameter value to 6$Workbook. SaveAs ("D:\My documents\work\public_ip_maps_infos22.csv", 6) $Excel. Quit ()

It is inefficient to read Excel row by line and then save it as CSV:

#Read Load Balancer information table$strpath="D:\My documents\work\ip Mapping table. xlsx"$excel=new-object-ComObject Excel.Application$WorkBook=$excel. Workbooks.Open ($strpath)$WorkSheet=$WorkBook. Worksheets.item (1)#number of rows used$usedrows=$worksheet. Usedrange.rows.count$Public _ip_maps_info=$Public _ip_maps_infos=$null$Public _ip_maps_infos= @()  for($i= 2;$i -le $usedrows;$i++){ $Public _ip_maps_info=""|Select PUBLIC_IP,INTERNAL_IP,IS_VIP$Public _ip_maps_info. public_ip =$WorkSheet. Cells.item ($i, 2). value2$Public _ip_maps_info. internal_ip =$WorkSheet. Cells.item ($i, 3). value2$Public _ip_maps_info. IS_VIP =$WorkSheet. Cells.item ($i, 4). value2$Public _ip_maps_infos+=$Public _ip_maps_info}$Public _ip_maps_infos$excel. Quit ()$WorkSheet=$null$WorkBook=$null$excel=$null[GC]:: Collect ()

To save CSV as Excel, refer to:

Http://www.pstips.net/converting-csv-to-excel-file.html

Save Excel as a CSV format file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.