Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a little bug when writing multiline texts to cells. #69

Closed
zzc-tongji opened this issue Jun 29, 2017 · 3 comments
Closed

There is a little bug when writing multiline texts to cells. #69

zzc-tongji opened this issue Jun 29, 2017 · 3 comments

Comments

@zzc-tongji
Copy link

Test Code

package main

import (
	"fmt"

	"github.com/Luxurioust/excelize"
)

func main() {
	// read
	xlsx, err := excelize.OpenFile("test-before.xlsx")
	if err != nil {
		fmt.Printf("%s\n", err.Error())
		return
	}
	table := xlsx.GetRows("sheet1")
	fmt.Printf("\n")
	fmt.Printf("Before:\n")
	for i := 0; i < len(table); i++ {
		for j := 0; j < len(table[0]); j++ {
			fmt.Printf("%s ", table[i][j])
		}
		fmt.Printf("\n")
	}
	// change
	xlsx.SetCellValue("sheet1", "A2", "A2\nExample 2")
	xlsx.SetCellValue("sheet1", "B2", "A2\n例子2")
	// write
	xlsx.SaveAs("test-after.xlsx")
	// read again
	xlsx, err = excelize.OpenFile("test-after.xlsx")
	if err != nil {
		fmt.Printf("%s\n", err.Error())
		return
	}
	table = xlsx.GetRows("sheet1")
	fmt.Printf("\n")
	fmt.Printf("After:\n")
	for i := 0; i < len(table); i++ {
		for j := 0; j < len(table[0]); j++ {
			fmt.Printf("%s ", table[i][j])
		}
		fmt.Printf("\n")
	}
	fmt.Printf("\n")
}

Test File

test-before.xlsx
test-before

test-after.xlsx
test-after

Test Environment

  • golang 1.8 darwin/amd64
  • Microsoft Excel 2016 for Mac

Problem

It seems like excelize can parse multiline texts in cells (with '\n' in the middle). However, multiline texts written by excelize could not be displayed correctly by Microsoft Excel, though they can be parsed correctly by excelize again.

@zzc-tongji
Copy link
Author

zzc-tongji commented Aug 19, 2017

I got it.

This is a little bug of Microsoft Excel 2016 for Mac.

Here is the solution: double click one of non-empty cells and then save.

After doing these, all multiline texts will be displayed correctly.

@xuri
Copy link
Member

xuri commented Jul 11, 2018

I close this and merge it into issue #172 is still discussing this problem.

@xuri xuri closed this as completed Jul 11, 2018
@xuri xuri mentioned this issue Sep 4, 2018
@xuri
Copy link
Member

xuri commented Apr 5, 2020

Hi @zzc-tongji, I have added rich text support for this lib, now it can be preserved multi-lines in the cell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants