如何使用import { Component } from "@angular/core";
import {AmountComponent} from "./amountcomponent.component";
@Component({
templateUrl: './dobcomponent.component.html'
})
export class DoBComponent {
public quantity:any;
childmessage : string = "I am passed from Parent to child component"
onquantity(event: any) {
this.quantity = event.target.value
console.log(this.quantity)
}
包将多行值写入CSV文件?
<input (keyup)="onquantity($event)">
<appchild [greetMessage]="childmessage"></appchild>
我期望在生成的CSV文件中得到的结果:
encoding/csv
我怎么能意识到这一点,因为fh, err := os.Create(fileName)
if err != nil {
log.Fatalf("Could not create file: %v", err)
}
defer fh.Close()
w := csv.NewWriter(fh)
normalValue := "I am a single line value"
multiValue := []string{"I am a ", "multi line value"}
w.Write([]string{normalValue, multiValue})
不接受I am a single line value,"I am a
multi line value"
作为论据?简单地在多行值的每个元素之间附加csv.Write
也不会实现任何目标。
答案 0 :(得分:1)
您需要在多行值中嵌入\n
。您可以执行此操作,例如,使用strings.Join
:
w.Write([]string{
normalValue,
strings.Join(multiValue, "\n"),
})