wb.add_worksheet(name: 'Report') do |sheet|
sheet.add_data_validation("D25", {
:type => :list,
:formula1 => 'list!D11:D17',
:showDropDown => false,
:showInputMessage => true,
:promptTitle => 'blah blah',
:prompt => 'Please select a valid blah'
})
end
我不知道如何填充下拉列表。该模板显示一个插入符号告诉我它知道我希望这是一个下拉列表。
答案 0 :(得分:3)
使用您的NSWindowCollectionBehaviorFullScreenAuxiliary
引用另一个名为NSResponder <NSApplicationDelegate>
的工作表。
如果仅引用// Create the window
self.Window = [NSWindow alloc];
[self.Window initWithContentRect:bounds
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:YES];
// Create the view
self.View = [NSView alloc];
[self.View initWithFrame:bounds];
[self.View setWantsLayer:YES]; // The generated layer is CAMetalLayer
// Associate the view with the window
[self.Window setContentView:self.View];
// Misc
[self.Window makeKeyAndOrderFront:self.Window];
[self.Window setAcceptsMouseMovedEvents:YES];
[self.Window setHidesOnDeactivate:YES];
// Fullscreen
[self.Window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
[self.Window toggleFullScreen:nil];
[self.Window makeFirstResponder:self.View];
,则会获得所选区域的值:
formula1 => 'list!D11:D17'
您可以使用list
- 引用,但必须将工作表命名为D11:D17
。
示例:
require 'axlsx'
Axlsx::Package.new do |p|
wb = p.workbook
wb.add_worksheet(name: 'Report') do |sheet|
sheet.add_data_validation("A10", {
:type => :list,
:formula1 => 'A1:A9',
:showDropDown => false,
:showInputMessage => true,
:promptTitle => 'blah blah',
:prompt => 'Please select a valid blah'
})
end
p.serialize('simple.xlsx')
puts "Wrote simple.xlsx"
end