大家好,又见面了,我是你们的朋友全栈君。
4 个答案:
答案 0 :(得分:1)
import openpyxl
from openpyxl.styles import Font, Color, colors
#…
# alternative 1: set hyperlink property to cell
def link_1(cell, link, display=None):
cell.hyperlink = link
cell.font = Font(u=’single’, color=colors.BLUE)
if display is not None:
cell.value = display
# alternative 2: use Excel formula HYPERLINK
def link_2(cell, link, display=’link’):
cell.value = ‘=HYPERLINK(“%s”, “%s”)’ % (link, display)
cell.font = Font(u=’single’, color=colors.BLUE)
# examples
link_1(ws[‘B2’], ‘#sheet3!A1’, ‘link_text’) # internal link
link_2(ws[‘B3’], ‘#sheet3!A1’, ‘link_text’) # internal link
link_1(ws[‘B4’], ‘https://www.google.com/’, ‘Google’) # web link
答案 1 :(得分:1)
您必须更改样式属性
cell.style = “Hyperlink”
答案 2 :(得分:0)
尝试添加像这样的超链接样式
#import
int main(int argc, const char * argv[]) {
@autoreleasepool {
Byte bytes[8];
bytes[0] = 0xFE;
bytes[1] = 0x03;
bytes[2] = 0x01;
bytes[3] = 0x00;
bytes[4] = 0xB4;
bytes[5] = 0x18;
bytes[6] = 0x01;
bytes[7] = bytes[1] ^ bytes[2] ^ bytes[3] ^ bytes[4] ^ bytes[5] ^ bytes[6];
NSData *data = [NSData dataWithBytes:bytes length:sizeof(bytes)];
NSLog(@”%@”, data);
NSString *str = [[NSString alloc] initWithBytes:&bytes length:8 encoding:NSUTF8StringEncoding];
NSLog(@”%@”, str);
}
return 0;
}
答案 3 :(得分:0)
我使用Font并且它有效。
from openpyxl.styles import Font
hyperlink = Font(underline=’single’, color=’0563C1′)
# …
cell.font = hyperlink
应该有一个名为Hyperlink的{{3}},但我还没有设法让它发挥作用……
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/161744.html原文链接:https://javaforall.cn